473,387 Members | 1,553 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,387 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 1184
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.