I have 5 different formulas stored in my database. I can choose the formula needed, but it just acts like a text string and I need it to calculate.

## 3 Replies - 2851 Views - Last Post: 05 April 2013 - 09:23 AM

### #1

# Calculate using a formula that is stored in a string expression

Posted 04 April 2013 - 12:27 PM

##
**Replies To:** Calculate using a formula that is stored in a string expression

### #2

## Re: Calculate using a formula that is stored in a string expression

Posted 04 April 2013 - 12:31 PM

... because they *are* strings. Just a series of characters. *You* need to give them life.. so you build an interpreter. Something that examines each each indexed character, deciphers if they are a variable, value, or operator... then asks the user to fill in the variables, and finally runs everything (values and operators) in proper math order of operations.

### #3

## Re: Calculate using a formula that is stored in a string expression

Posted 04 April 2013 - 12:36 PM

VB6 doesn't have an eval() function to evaluate an expression. It is possible to do this by referencing VBScript and using its Eval function. Otherwise, you would need to parse the string-expression yourself, converting its various parts to variable-values and function calls.

### #4

## Re: Calculate using a formula that is stored in a string expression

Posted 05 April 2013 - 09:23 AM

andrewsw, on 04 April 2013 - 12:36 PM, said:

VB6 doesn't have an eval() function to evaluate an expression. It is possible to do this by referencing VBScript and using its Eval function. Otherwise, you would need to parse the string-expression yourself, converting its various parts to variable-values and function calls.

Thanks! than answers my question~!

Page 1 of 1