Table of Contents [Hide/Show]
Definitions Coding a Base Class and Derived Classes Using Derived Classes Example Base Class Derived Class Main Routine
Public
Implements BaseClass
Private Property Get BaseClass_BaseName() as DataType (code) End Property
BaseClass_BaseName
Private
Dim objMyObject as MyBaseClass
Set objMyObject = New MyDerivedClass
objBase.DerivedProperty = PropertySetting
Dim objDerived as DerivedClass Set objDerived = objBase objDerived.SupplementalMethod
Option Explicit Public Sub Speak() End Sub Public Property Get Name() As String End Property Public Property Let Name(x As String) End Property Public Sub WhoAmI() End Sub
Option Explicit Implements Animal Private strName As String Private Sub Animal_Speak() MsgBox "I'm a dog" End Sub Public Sub Bark() MsgBox "Bark!" End Sub Friend Property Get Animal_Name() As String Animal_Name = strName End Property Private Property Let Animal_Name(x As String) strName = x End Property Private Sub Animal_WhoAmI() With Me MsgBox "I am " & .Animal_Name End With End Sub Private Sub Class_Terminate() MsgBox "Doggy Dead" End Sub
Option Explicit Sub main() Dim animX As Animal, dogY As Dog Set animX = New Dog Set dogY = animX animX.Name = "Fido" animX.Speak animX.WhoAmI dogY.Bark End Sub
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.