Convert a string into a mathematical formula!

Cocis91

Registered User.
Local time
Today, 16:04
Joined
Dec 30, 2000
Messages
14
I have a field in a form and I want a person to be abkle to type in a calculation expression and then to press a button to get the answer in another box.

For example, you might type into the text box :

(4+5)/3

The thing I don't know how to do here is to create a function which grabs the above string expression and then converts it into a non-string and then actually does the calculation. I don't know a great deal about VB but there must be a function which will make sense of the string expression, as long as it is a mathematically valid expression.

Any help gratefully received.
 
It might be easier if you added a calulator into your form. Try this sample by Ricky Hicks for you can easily add it into your form.

Calculator

HTH
 
I like ghudson's suggestion, alternatives to consider are:

1) Use the eval function to do the calculations: MsgBox Eval(Me.Text0) where Me.Text0 contains your formula

or

2) Use the shell command to start up the built-in calculator.

Shell "C:\WINDOWS\CALC.EXE", vbNormalFocus
 

Users who are viewing this thread

Back
Top Bottom