Основы офисного программирования и язык VBA


Пример 5.3


Public Sub Family()

Dim F As New Father, S As New Son, GS As New GrandSon

Dim Grand As Father, GrandS As Son

Set Grand = F

Grand.MyProperty = "Flat"

Grand.MyRealMethod

Grand.MyPureMethod

Debug.Print Grand.MyProperty

Set Grand = S

Grand.MyProperty = "Flat"

Grand.MyRealMethod

Grand.MyPureMethod

If TypeOf Grand Is Son Then

Set GrandS = Grand: GrandS.SonNewMethod

End If

Debug.Print Grand.MyProperty

Set Grand = GS

If TypeOf Grand Is GrandSon Then

Set GrandS = Grand: GrandS.SonNewMethod

End If

Grand.MyProperty = "Flat"

Grand.MyRealMethod

Grand.MyPureMethod

Debug.Print Grand.MyProperty

End Sub




Начало  Назад  Вперед



Книжный магазин