vbs 类的使用示例

 

Class Myclass

 ' Class_Initialize
    Private Sub Class_Initialize
   MsgBox  "Class is initialized"
    End Sub

 ' Class_Terminate
    Private Sub Class_Terminate
  MsgBox "Class is terminated"
    End Sub

 ' Member variables
    Public m_varValue

 'Get the value of  Member variables
    Public Property Get varValue
        varValue = m_varValue
    End Property

 ' Set the value of  Member variables
    Public Property Let varValue(newValue)
        m_varValue = newValue
    End Property 

 ' Sub
    Sub sub_test(s)
        MsgBox s
    End Sub

    ' Function
    Function fun_test(f)
        MsgBox f
    End Function

End Class

'  -  -  - test the class -  -  -  -  -

Set newClass = New Myclass
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")

你可能感兴趣的:(Class,Class,vbs,vbs)