mholywell
asked on
script control accessing variables
The documentation on Microsofts web site suggests script control can be used to update variables..
why when I try scriptcontrol1.executestat ement "x=100"
does nothing happen
I've tried sc.addcode:
sub inc(x)
x=x+1
msgbox(x)
end sub
and sure enough the messagebox shows x(on call)+1 but x isn't updated in my program.. and I've tried byref x.
And, finally, I've repeated the test as JScript.
Is the documentation misleading or am I being stupid?
why when I try scriptcontrol1.executestat
does nothing happen
I've tried sc.addcode:
sub inc(x)
x=x+1
msgbox(x)
end sub
and sure enough the messagebox shows x(on call)+1 but x isn't updated in my program.. and I've tried byref x.
And, finally, I've repeated the test as JScript.
Is the documentation misleading or am I being stupid?
Documentation (help file) is a bit hidden, but try:
winhelp MSScript
in the Run dialog (Start, Run)
winhelp MSScript
in the Run dialog (Start, Run)
ASKER
To Ameba: Thanks..
The pointer to the documentation was handy - it looks like I've got to use .addobject if I want to return multiple values from my routine but I can't get executeStatement to work as per their example.
I'm working on create object and call to get round my earlier problem Q.10149829 but calls from within a vbscript appear to be byval (though the strong typing problem goes away!)
Claim the points.. but if you want a problem to solve try call byref from within a vbscript!
The pointer to the documentation was handy - it looks like I've got to use .addobject if I want to return multiple values from my routine but I can't get executeStatement to work as per their example.
I'm working on create object and call to get round my earlier problem Q.10149829 but calls from within a vbscript appear to be byval (though the strong typing problem goes away!)
Claim the points.. but if you want a problem to solve try call byref from within a vbscript!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This script control seems to do everything except allow me to get round my callbyname problem...
I will continue the search!
Thanks
I will continue the search!
Thanks
On Error GoTo runerr
' Add the code, then run the function.
ScriptControl1.AddCode Text1.Text
Dim ret As String
ret = ScriptControl1.Run("inc")
MsgBox ret, vbOKOnly, "Function returned"
Debug.Print ret
Exit Sub
runerr:
Exit Sub
End Sub
' in your script, add
inc = x