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

  • Thread starter Thread starter JM
  • Start date Start date
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
 
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
 
Back
Top