|
-
Oct 31st, 2007, 09:12 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Compute expression
Hello.
Is there any VB function which allows to compute an expression?
Example:
In a textbox input:"2+2"
On button click
msgbox compute (me.text1)
Thank you
-
Oct 31st, 2007, 09:26 AM
#2
Re: Compute expression
Add a reference to the component: Microsoft Script Control 1.0
Code:
Private Sub Command1_Click()
Dim script As ScriptControl
Set script = New ScriptControl
script.Language = "VBScript"
Debug.Print script.Eval("2+2")
End Sub
-
Oct 31st, 2007, 09:27 AM
#3
Re: Compute expression
You could add the Microsoft Script Control to your Form and the use code simular to this:
vb Code:
MsgBox ScriptControl1.Eval(Text1.Text)
Edit: I'm just too slow today
-
Oct 31st, 2007, 09:32 AM
#4
Frenzied Member
Re: Compute expression
Add a Microsoft Script Control to your components. Add new component to your form. use like
Code:
ScriptControl1.Eval("2+2")
There are some examples here. search and see.
-
Oct 31st, 2007, 09:33 AM
#5
Frenzied Member
Re: Compute expression
I m damn slow, as usual
-
Oct 31st, 2007, 09:55 AM
#6
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|