Valhalla Legends Forums Archive | Visual Basic Programming | Exposing VB sub for use in VBS

AuthorMessageTime
FrostWraith
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.
September 2, 2006, 2:24 AM
Stealth
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.
September 2, 2006, 6:25 AM
FrostWraith
I can't quite seem to get it. Here is what I am doing:
Code in Class Module (clsScriptSupportClass):
[code]Public Sub MessageBox(strMessage As String, strTitle As String)
    MsgBox strMessage, , strTitle
End Sub[/code]

Code in Form (frmMain):
[code]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[/code]
September 2, 2006, 8:45 PM
rabbit
A sub is not an object.  You have pass the entire class, not just a sub.
September 2, 2006, 10:00 PM
FrostWraith
Wow, im a retard. Thx.
September 3, 2006, 2:37 AM

Search