Class Cfoo
Dim Publicparam ' Declare public member variables with Dim
Private Privateparam ' privacy member variable
' Publicparam = ' public ' cannot be assigned to a member variable within a class tag, outside of a class function
' Const Max_len = 5 ' cannot use const outside of class tags, classes functions
' This function is a constructor that automatically executes when an object is created using set new
Private Sub Class_Initialize ()
Publicparam = "Public" can assign a value to a member variable here
Privateparam = "Private"
End Sub
' This function is a destructor that automatically executes when the object is disposed with set nothing
Private Sub Class_Terminate ()
Response. Write "Release Object"
End Sub
' Public member function (procedure)
' member function (procedure) not required or declared
Sub PrintParam (Index)
If index = 1 Then
Call Printpublicparam ()
ElseIf index = 2 Then
Call Printprivateparam ()
End If
End Sub
' Private member function (procedure)
' Just one more private than the public member function (process)
Private Sub Printpublicparam ()
Response. Write Publicparam
End Sub
Private Sub Printprivateparam ()
Response. Write Privateparam
End Sub
End Class
Dim obj
Set obj = new Cfoo ' Automatically calls the Class_Initialize function, assigning values for Publicparam, Privateparam
Obj.publicparam = "New Public"
Obj.privateparam = "New Private" will have an error because Privateparam is a private variable
Call obj. PrintParam (1) ' shows the value of the Publicparam
Call obj. Printpublicparam () ' will cause an error because printpublicparam is a private function
Set obj = Nothing ' automatically calls the Class_Terminate function, displaying ' release object '