Call Test
Class Tester
Dim mvarTesterName,mvarAge,mvarGender
Sub Class_Initialize '构造函数
MsgBox "接下来,大家欢迎新同事的到来!"
End Sub
Sub Class_Terminate '析构函数
If mvarGender Then
MsgBox "很遗憾," & mvarTesterName & "先生脱离了测试行业!"
Else
MsgBox "很遗憾," & mvarTesterName & "女士脱离了测试行业!"
End If
End Sub
Sub Test(ByVal ProjectName)
MsgBox mvarTesterName & "正在加班加点的测试" & ProjectName & "呢!"
End Sub
Sub Eat(ByVal food)
MsgBox mvarTesterName & "正在吃" & food & "呢,好爽啊!"
End Sub
Property Let Gender(ByVal vData)
mvarGender = vData
End Property
Property Get Gender()
Gender = mvarGender
End Property
Property Let Age(ByVal vData)
mvarAge = vData
End Property
Property Get Age()
Age = mvarAge
End Property
Property Let TesterName(ByVal vData)
mvarTesterName = vData
End Property
Property Get TesterName()
TesterName = mvarTesterName
End Property
End Class
Sub Test()
Set sb = New Tester '创建一个对象,对象名叫somebody,它是由Tester创建出来的
sb.TesterName = "songfun"
sb.Age = 29
sb.Gender = True
sb.Eat "HagenDaz"
sb.Test "手机"
If sb.Gender Then
MsgBox sb.TesterName & "先生年方" & sb.Age
Else
MsgBox sb.TesterName & "女士芳龄" & sb.Age
End If
Set sb = Nothing
End Sub
'****************************************************************
手机扫一扫
移动阅读更方便
你可能感兴趣的文章