Help! How to evaluate a math expression (in text format)

  • Thread starter Thread starter JM
  • Start date Start date
J

JM

Hi,

I have an string with a math expression, example str = "Log(5) +3 "

How can i convert it into a numeric value?

Thanks,

Jaime
 
You will have to treat the Log(5)+3 as an Integer value to get the answer,
then you can change it to a string. Where is Log(5) coming from? is that
an Interger value?

You could do something like this:

Dim intX as Integer
Dim strMyValue as String

intX = Log(5) + 3

strMyValue = intX
 
Simply use the eval functon.

dim str as string

str = "log(5) + 3"

msgbox "result = " & eval(str)
 
Back
Top