I'm implementing an external script file for the first time. But I would like to use some subs that are used in my VB project. How do I expose them to be available for use in the script file.
Add them to a class object, instantiate that object, then use the script control's .addObject method to allow your scripts to access that instance.
I can't quite seem to get it. Here is what I am doing:
Code in Class Module (clsScriptSupportClass):
Public Sub MessageBox(strMessage As String, strTitle As String)
MsgBox strMessage, , strTitle
End Sub
Code in Form (frmMain):
Private SSC As New clsScriptSupportClass
Private Sub Form_Load()
Call VBScript.AddCode(ReadScript(App.Path & "\Scripts\script.txt"))
Call VBScript.AddObject("MessageBox", SSC, True)
Call VBScript.Run("Event_Load")
End Sub
A sub is not an object. You have pass the entire class, not just a sub.
Wow, im a retard. Thx.