Dynamic variable names without EVAL - NEWBIE

  • Thread starter Thread starter jason
  • Start date Start date
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!
 
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...
 
Back
Top