• Welcome to Valhalla Legends Archive.
 

Exposing VB sub for use in VBS

Started by FrostWraith, September 01, 2006, 09:24 PM

Previous topic - Next topic

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.

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.
- Stealth
Author of StealthBot

FrostWraith

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

rabbit

A sub is not an object.  You have pass the entire class, not just a sub.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

FrostWraith