Evaluating an expression described in a string?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone know how I can do this? No eval function in VB.Net unfortunatley

Dim strExpression As string = "itemsPurchased>5
If eval(strExpression) The
giveDiscount(
End If
 
DataViews allow you to provide a filter and sort expression.

Otherwise you need to look into parsing it yourself (perhaps a 3rd party
component), or .NET Scripting, or something similar.
-mike
MVP
 
it's not so straightforward, but you can look up
Microsoft.VisualBasic.VBCodeProvider in MSDN - you can CreateCompiler()
with which you can compile a VB assembly. the rest is code generation
- I've done it with C#
 
Back
Top