Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: FrostWraith on September 01, 2006, 09:24 PM

Title: Exposing VB sub for use in VBS
Post by: FrostWraith on September 01, 2006, 09:24 PM
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.
Title: Re: Exposing VB sub for use in VBS
Post by: Stealth on September 02, 2006, 01:25 AM
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.
Title: Re: Exposing VB sub for use in VBS
Post by: FrostWraith on September 02, 2006, 03:45 PM
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
Title: Re: Exposing VB sub for use in VBS
Post by: rabbit on September 02, 2006, 05:00 PM
A sub is not an object.  You have pass the entire class, not just a sub.
Title: Re: Exposing VB sub for use in VBS
Post by: FrostWraith on September 02, 2006, 09:37 PM
Wow, im a retard. Thx.