Dynamic variable names without EVAL - NEWBIE

J

jason

I'd like to write an asp.net-VB subroutine that accepts the name of an
itemlist as a parm to be populated. I think under classic ASP I would
use EVAL() to accomplish dynamic code like this. How would I do this
in ASP.NET-VB?


For example in the code below I'd like pass nnnnnn in. Of course this
code as-is will not work.


<vb code snippet>

sub loaditems(nnnnnn as string, regstring as string)

Dim regexp as Regex = New Regex(regstring, RegexOptions.IgnoreCase)
Dim objMatch as Match
dim z as string
For Each objMatch in regexp.Matches(session("readin"))
z = objMatch.ToString()
nnnnnn.items.add(z)
Next
end sub

</vb code?>

Many Thanks in Advance for any help or info!
 
C

Craig Deelsnyder

I'd like to write an asp.net-VB subroutine that accepts the name of an
itemlist as a parm to be populated. I think under classic ASP I would
use EVAL() to accomplish dynamic code like this. How would I do this
in ASP.NET-VB?


For example in the code below I'd like pass nnnnnn in. Of course this
code as-is will not work.


<vb code snippet>

sub loaditems(nnnnnn as string, regstring as string)

Dim regexp as Regex = New Regex(regstring, RegexOptions.IgnoreCase)
Dim objMatch as Match
dim z as string
For Each objMatch in regexp.Matches(session("readin"))
z = objMatch.ToString()
nnnnnn.items.add(z)
Next
end sub

</vb code?>

Many Thanks in Advance for any help or info!

There is no eval statement in VB.NET. I believe only JScript.NET
supports it. A couple of people have made workarounds though

http://www.codeproject.com/dotnet/evaluator.asp?target=evaluator
http://www.codeproject.com/csharp/runtime_eval.asp?target=evaluator

there are others on that site as well...
 

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

Similar Threads


Top