VB2005 execute string

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)
 
C

Cowboy \(Gregory A. Beamer\)

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.
 
J

Jerzy Zielinski

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
 
C

Cowboy \(Gregory A. Beamer\)

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top