Convert String to Math function/expression!!
Hi,
What I'm looking to do is this:
label1.caption = 25 * textbox1.text
where textbox1.text = "Cos(45.0)"
I'm trying to use the string "Cos(45.0)" in a calculation to obtain a numerical value. However, I can't seem to get it to recognise that the string is a math expression. The return value is zero when using Val(textbox1.text).
Please help!
Thanks
Re: Convert String to Math function/expression!!
Add (from Components dialog) Microsoft Script Control to your project and then to your form.
When you done you can use like this:
Code:
Private Sub Command1_Click()
Label1.Caption = 25 * ScriptControl1.Eval(Text1.Text)
End Sub