Add the MS script control to a form in your project.
Use can then use the eval method. E.g.
----------------------------------------------------------
Dim n As Integer
ScriptControl1.ExecuteStatement ("i=2"
n = ScriptControl1.Eval("i+1"
MsgBox
---------------------------------------------------------- Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
Ok, first of all you need to add a refererence to the Microsoft Script Control (although you can do late binding and avoid the reference if you prefer). Then, for this example, you need a form with a textbox, a label and a command button. You will be able to enter calcuations into the textbox (e.g 2+5, (2+6)/4), and hit the command button to get the result in the label. You just need to drop in the following code: [tt]
Option Explicit
Private Sub Command1_Click()
Dim wsh As ScriptControl 'Change to As Object if you don't want to add a refference
' Done this way rather than with New to cater for the fact we may have decided not to add a reference
' and therefore wsh may be declared As Object.
Set wsh = CreateObject("MSScriptControl.ScriptControl"
wsh.Language = "vbscript" ' Vital - must tell script control which of the several script languages it is to use
In the Project menu, select Components. Make sure "Selected Items Only" is unchecked. Then select "Microsoft Script Control x.x" from the list.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.