VB2005 execute string

  • Thread starter Thread starter Jerzy Zielinski
  • Start date Start date
J

Jerzy Zielinski

Hi all,

I would like to execute/evaluate a string that contains a VB script,
for example:
Dim s as string = "Dim avar as integer = 1"
' Evaluate s...
so s can be executed during runtime and avar will be created as a
result.

Thanks.
Jerzy
(e-mail address removed)
 
Reflection gives you the ability to emit code and run it. There is no direct
equivalent of the java (or JavaScript) eval function, but you can wrap the
attempt in an exception handler.

There is probably another way to play this game.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
 
Thank you for this sugestion.

OK. If there is no "eval", like in java. Maybe there is a way to
iterate the variable names to generate them automaticly with different
prefixes or suffixes. Something like: var1, var2, var3, ... varn. or
to pass a prefix in a function, procedure, sub call prefix & canstant
name would give a name of a boxes or lables in a page; like st_box,
nd_box, rd_box so in function call there is function_name("st"), and
in function there is variable&"_box".Text = "some text"


Thank you in advance
Jerzy
 
If you want to dynamically put out controls, that is simple. Just set a
container control, like a panel, and add controls to it. You can get far
more complex if you use data bound controls, like a GridView, etc., and add
code to the row databinding event. This allows you to alter the output to
fit your shims. If you then want to grab values, you can iterate through the
controls collection when the page is posted back.

Am I getting close?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
 
Back
Top