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

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
 
R

RC-

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
 
A

Albert D. Kallal

Simply use the eval functon.

dim str as string

str = "log(5) + 3"

msgbox "result = " & eval(str)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top