My Really Programmable Calculator program defines several objects that can be used in the VBScript program. I do this when I load the calculator form, as you can see in Listing 13.9. I also set the SSTab control to the Keyboard View, initialize the FileSystemObject, and call the LoadCode routine to load the default script program.
Listing 13.9: Form_Load Event in Programmable Calculator
Private Sub Form_Load()
ScriptControl1.AddObject “Display”, Display
ScriptControl1.AddObject “XRegister”, XRegister
ScriptControl1.AddObject “YRegister”, YRegister
ScriptControl1.AddObject “ZRegister”, ZRegister
ScriptControl1.AddObject “OpRegister”, OpRegister
SSTab1.Tab = 0
Set fso = New FileSystemObject
LoadCode
End Sub
Defining the objects is a very simple process. All you need to do is call the AddObject method and specify the object’s script name and real name. Inside your script program, you will refer to the object by its script name, while you will continue to refer to the object by its real name in your Visual Basic 6 application.