Article ID: 184322
Article Last Modified on 5/13/2003
Property Get MyFirstProperty() As String
End Property
Implements clsBase
Private Property Get clsBase_MyFirstProperty() As String
clsBase_MyFirstProperty = "Hello from MyFirstProperty!"
End Property
Public Function CreateDerivedClass() As clsBase
Set CreateDerivedClass = New clsDerived
End Function
' 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 : " & _
TypeName(oEarlyDerivedClass)
' To prove that an instance of the derived class was successfully
' created, call the base class's interface, which the derived
' class implemented.
MsgBox oEarlyDerivedClass.MyFirstProperty
' Destroy our objects.
Set oEarlyDerivedClass = Nothing
Set oEarlyStarterClass = Nothing
End Sub
Private Sub Command2_Click()
' Create an instance of the out-proc server starter class object
' late-bound.
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
' class.
MsgBox "oLateDerivedClass Is Of Type : " & _
TypeName(oLateDerivedClass)
' Finally, try to call the property that the derived class
' has implemented. This will fail!
MsgBox oLateDerivedClass.MyFirstProperty
End Sub
Additional query words: kbVBp500bug kbVBp600bug kbdss kbDSupport kbVBp kbActiveX
Keywords: kbbug kbpending KB184322