' 创建一个名为className的类
Class className
' 构造函数
Private Sub Class_Initialize
MsgBox "一个类实例被创建"
End Sub
' 析构函数
Private Sub Class_Terminate
MsgBox "析构类实例"
End Sub
' 成员变量
Public m_varValue
' 获取成员变量的值
Public Property Get varValue
varValue = m_varValue
End Property
' 设置成员变量的值
Public Property Let varValue(newValue)
m_varValue = newValue
End Property
' 过程
Sub sub_test(s)
MsgBox s
End Sub
' 函数
Function fun_test(f)
MsgBox f
End Function
End Class
' - - - test the class - - - - -
Set newClass = New className
newClass.m_varValue = "this is a varValue"
MsgBox newClass.m_varValue
newClass.sub_test("this is a test of the sub")
newClass.fun_test("this is a test of the funtion")