I got "2 + 2" in a string variable.
I would like to know if it's possible to actually execute/calculate that STRING to obtain the result of "4".
I don't feel like parsing/messing with the string, unless I have no choice.
Thank you!
Printable View
I got "2 + 2" in a string variable.
I would like to know if it's possible to actually execute/calculate that STRING to obtain the result of "4".
I don't feel like parsing/messing with the string, unless I have no choice.
Thank you!
You can use the Eval Method for that.
Code:'project >> references >> microsoft script control 1.0
Dim msc As New MSScriptControl.ScriptControl
Dim Str1 As String
Str1 = "2 + 2"
msc.Language = "vbscript"
MsgBox msc.Eval(Str1)