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

Page 1 of 1

## 3 Replies - 2310 Views - Last Post: 05 April 2013 - 09:23 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=317650&amp;s=be74f61782646fe74de428c2e700db81&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Jwebb360

Reputation: 0
• Posts: 2
• Joined: 04-April 13

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

Posted 04 April 2013 - 12:27 PM

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.
Is This A Good Question/Topic? 0

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

### #2 modi123_1

• Suitor #2

Reputation: 11593
• Posts: 45,749
• Joined: 12-June 08

## 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 andrewsw

• But the opposite, you said.

Reputation: 5518
• Posts: 21,772
• Joined: 12-December 12

## 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 Jwebb360

Reputation: 0
• Posts: 2
• Joined: 04-April 13

## 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.