473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Evaluating an expression described in a string?

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
Nov 22 '05 #1
3 1182
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

"Ditchit" <an*******@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
Anyone know how I can do this? No eval function in VB.Net unfortunatley.

Dim strExpression As string = "itemsPurchased>5"
If eval(strExpression) Then
giveDiscount()
End If

Nov 22 '05 #2
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#

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

Dim strExpression As string = "itemsPurchased>5"
If eval(strExpression) Then
giveDiscount()
End If


Nov 22 '05 #3
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#

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

Dim strExpression As string = "itemsPurchased>5"
If eval(strExpression) Then
giveDiscount()
End If


Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kurt hansen | last post by:
hi I thought that this would be easy, but maybe not so much. I want to: pass an xpath expression and a string value to a stylesheet and copy the source xml document, changing the value of...
2
by: Ditchit | last post by:
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
1
by: Saira | last post by:
Hello al I am not sure where to post this, so I hope this is correct. We have written a Visual Studio AddIn that relies heavily on regular expressions, which are often executed...
3
by: Kevin Rollo | last post by:
I'm playing with a generic routine to export data, the concept is to have a list of data driven templates defining what fields to output. Evaluating a simple variable field name in the function...
11
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend...
3
by: DeerGuy | last post by:
This is a really, really simple question, but I so new to VBA, that I have to ask. I have an integer variable that I want to perform some actions on depending upon its value. Is the following...
6
by: bugnthecode | last post by:
I'm writing a program to send data over the serial port. I'm using pyserial, and I'm on WindowsXP. When I use literals I can get the data accross how I want it for example: 1 2 3 4...
4
by: jman | last post by:
var x = eval("{ 'flag' : 1 }"); alert(x); alert(x.flag); why doesn't the above work?
4
by: jake | last post by:
Is there a way to evaluate a string expression such as "55/8" to return 6.875? Your help is greatly appreciated. jake
6
by: eureka2050 | last post by:
Hi, I am a PHP coder, recently ran into a bit of a problem trying to evaluate expressions in PHP. I have an expression which is stored in a string variable and when I try to evaluate it, it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.