3 Replies - 843 Views - Last Post: 05 April 2013 - 09:23 AM Rate Topic: -----

#1 Jwebb360  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,122
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2884
  • View blog
  • Posts: 9,566
  • 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.
Was This Post Helpful? 1
  • +
  • -

#4 Jwebb360  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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

View Postandrewsw, 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~!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1