×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
Is there ANY way to find or make a EVALUATE function like FoxPro or Javascript in VB5?
eval("2 + 2") = 4

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

Why not use the Immediate window to Evaluate Expressions. Or am I not understanding your question

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

(OP)
I need to make functions and evaluate formulas that are a result of an input from the user.
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:

expres="first * second + (days - notworkedays) * salary" that are suppose to be input by the user.

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.
But I still have to figure it out how to do it with VB

I guess I will have to find a way around and use it on a SQL query. But so far no luck.
Thanks anyway

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

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.

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.

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

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 !!!

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 !

Check out for the MSSCRIPT.OCX in your systems folder and see the Microsoft website !

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

Hi,

Or you can use the Expression Evaluator code that appeared in VBPJ Feb 98 issue(could handle variables also).

There are also quite a few of those floating around on the web, get one most suited to your needs and modify.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close