Default
Used only w
ITh the Public keyword in a Class block to indicate t
hat the Function
PRocedure is the default method for the class. An error occurs if more than one Default procedure is s
PEcified in a class.
Class MyClass
Public Default Function SayHello(n
ame)
SayHello = "Hello, " &am
p; name
End Function
End Class
Set o = New MyClass
MsgBox o("demon")
Class
testClass
'
SETUP Initialize event.
Private Sub Class_Initialize
MsgBox("TestClass started")
End Sub
' Setup Terminate event.
Private Sub Class_Terminate
MsgBox("TestClass terminated")
End Sub
End Class
' Create an instance of TestClass.
Set X = New TestClass
' Destroy the instance.
Set X = Nothing
'Author: Demon
'Date: 2011/09/29
'Website: http://demon.tw
Class Rectangle
Private h
eight, width
Public Default Function Construtor(h, w)
height = h : width = w
Set Construtor = Me
End Function
Public Property Get Area
Area = height * width
End Property
End Class
'看起来是不是很像构造函数呢
Set r = (New Rectangle)(6, 8)
MsgBox r.Area