Hi,
I store a formula in the database such as the following:
GrossIncome+(Overtime/0.5)-Deductions=BasicNetIncome
I am able to substitute the string representations with actually values entered, thus:
1000+(150*0.5)-100=BasicNetIncome
Then I remove the '=BasicNetIncome', thus:
1000+(150*0.5)-100
How can evaluate the above equation to return a result:
My code:
Dim s as String="1000+(150*0.5)-100"
Dim d as Decimal=CDEC(s) '-- Throws An InvalidCastException.
However if I execute from the immediate or console window, it returns the result:
? Cdec(1000+(150*0.5)-100) ''Works in console window. Return 975
How can I get it to work in code?
I store a formula in the database such as the following:
GrossIncome+(Overtime/0.5)-Deductions=BasicNetIncome
I am able to substitute the string representations with actually values entered, thus:
1000+(150*0.5)-100=BasicNetIncome
Then I remove the '=BasicNetIncome', thus:
1000+(150*0.5)-100
How can evaluate the above equation to return a result:
My code:
Dim s as String="1000+(150*0.5)-100"
Dim d as Decimal=CDEC(s) '-- Throws An InvalidCastException.
However if I execute from the immediate or console window, it returns the result:
? Cdec(1000+(150*0.5)-100) ''Works in console window. Return 975
How can I get it to work in code?