' Early bound object references.
Dim oEarlyStarterClass As OutProcServer.clsStarter
Dim oEarlyDerivedClass As OutProcServer.clsBase
' Late bound object references.
Dim oLateStarterClass As Object
Dim oLateDerivedClass As Object
Private Sub Command1_Click()
' Create an instance of the out-proc server starter class object.
Set oEarlyStarterClass = New clsStarter
' Now that there is a reference to the starter class object; use
' this object to return an instance of the derived class, which
' implements the base class declared in the out-proc server.
Set oEarlyDerivedClass = oEarlyStarterClass.CreateDerivedClass
' Show the object type of the newly created object returned
' from the starter class object; it will be the derived class.
MsgBox "oEarlyDerivedClass Is Of Type : " & _
' To prove that an instance of the derived class was successfully
' created, call the base class's interface, which the derived
' class implemented.
' Destroy our objects.
Set oEarlyDerivedClass = Nothing
Set oEarlyStarterClass = Nothing
Private Sub Command2_Click()
' Create an instance of the out-proc server starter class object
Set oLateStarterClass = CreateObject("OutProcServer.clsStarter")
' Create a late-bound instance of the derived class.
Set oLateDerivedClass = oLateStarterClass.CreateDerivedClass
' The first test is to show the type of the object that was just
' created through the starter class object. The MsgBox will show
' the correct value; which is the derived class, and not the base
MsgBox "oLateDerivedClass Is Of Type : " & _
' Finally, try to call the property that the derived class
' has implemented. This will fail!