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>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.