Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EVALUATE() FUNCTION IN VB, Is it out there? 2

Status
Not open for further replies.

hug

Programmer
Mar 14, 1999
46
0
0
VE
Is there ANY way to find or make a EVALUATE function like FoxPro or Javascript in VB5?<br>
eval("2 + 2") = 4<br>

 
Why not use the Immediate window to Evaluate Expressions. Or am I not understanding your question
 
I need to make functions and evaluate formulas that are a result of an input from the user.<br>
I found a recursive parser to evaluate basic functions, I found it in the support library at the microsoft support web site, but I need to understand how to execute at running time something like:<br>
<br>
expres="first * second + (days - notworkedays) * salary" that are suppose to be input by the user.<br>
<br>
I know that I can evaluate function and expresions using Javascript Visual Fox Pro, with the function eval(expres) in JS or with execute.evaluate(express) in FoxPro.<br>
But I still have to figure it out how to do it with VB<br>
<br>
I guess I will have to find a way around and use it on a SQL query. But so far no luck.<br>
Thanks anyway
 
There is an Eval function in VBA that does that, so I'd assume there is one in VB. Do a search for eval in the Object Browser - that's what I did.<br>
<br>
Either that or write your own routine to do it. I had to write one a few years back for a course I was on - I seem to remember having to use stacks to keep track of brackets and all that kind of stuff.
 
You could also use VBScript as a component ('Microsoft Script Control 1.0' or higher), included into your application. You can then fully dynamically create code (such as subroutines etc.) and have them run without any compilation or whatever !!!<br>
<br>
OK, OK, it's a heavy solution for what you want to do, but you can keep it's use simpler than creating subs and so, and you gain almost infinte power !<br>
<br>
Check out for the MSSCRIPT.OCX in your systems folder and see the Microsoft website !
 
Hi,<br>
<br>
Or you can use the Expression Evaluator code that appeared in VBPJ Feb 98 issue(could handle variables also).<br>
<br>
There are also quite a few of those floating around on the web, get one most suited to your needs and modify.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top