Help!! How to evaluate a Math function in string form

J

JM

Hi,

I have a math function and need to obtain its value, the math function is in
a string, example:

str = "(3)^2 + 23"

How can I evaluate str??

Thanks,

Jaime
 
A

Albert D. Kallal

Try pasting the following code into a module..and then just whack f5 when
your cursor is in the code

Sub t1()

Dim strEx As String

strEx = InputBox("enter expression")

If strEx <> "" Then
MsgBox "the result of " & strEx & " is " & vbCrLf & _
Eval(strEx)

End If



End Sub


When the above runs...simply enter your expression of:

(3)^2 + 23
 

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