First, the (VBScript) class is composed of events and methods (they are members of the constituent class). If you have not touched, you can first look at the following description (haha, I am now selling, said Not good, please forgive me.
In the Class block, the member is declared by the corresponding statement statement as Private (private member, only within the class internal) or public (public member, can be called within the class). The declared Private will be visible only in the Class block. Declare that PUBLIC is not only visible inside the Class block, and it is also visible to the code outside the Class block. Did not use Private or public clearly declared by default as public. The process (SUB or FUNCTION) that is declared as public is declared as a process of publication. Public variables will become the properties of the class, just like the properties explicitly declared using the Property Get, Property Let, and Property Set. The default attributes and methods of classes are specified by the default keywords in their declaration.
Please read the blue part in your heart. Let's take an example.
Class myclass' // ---- Declaration (Declaring is defined) MyClass class Class Interior (Private [Private]) Variable Private Strauthor Private Strversion Private strexample
'// ------------------------- Define the event ---------------------------------------------------------------------------------------------- --------------- // '// ---- Class_Initialize () is an initialization event of a class, as long as you start using this class, first trigger the execution of the part, below us The author and version of the class will be initialized in the member and display it on the screen.
Private sub coplass_initialize () stradu = "Source" strVersion = "1.0" response.write "
MyClass started
" End sub '//-- class_terminate () is the end of the class, as long as an exit This class will trigger the event. Below we will set out the class in the event, it is over the screen.
Private sub coplass_terminate () response.write "
Myclass ended
" End Sub
'// --------------------------- User's own definition method --------------- ---------------- //
'// ---- This method returns a version of the information pub information () response.write
Coding by maxid_zen @ www.design60s.com "End Sub '// ------------------ --------- Define the output attributes of the class ----------------------------- //
'// - Class-class properties, this property is to initialize the strexApMle variable
Public property lette setExapmle (Byval strvar) strexapmle = strvar End Property
'// ------------------------- Define the output attribute of the class ------------- ---------------- //
'// ---- Define the properties of the class, this property is returned to a version number
Public Property Get Version Version = StrVersion End Property
'// --- Define the properties of the class, this property is the author of the class
Public property Get Author Author = Strauthor End Property
'// ---- Define the properties of the class, this property is returns a custom value
Public property Get Example EXAMPLE = strexample End Property
END CLASS
script> <%
'// ------- Here is an example using this class
Dim Onenewclass
Set onnenewclass = new myclass
Response.Write "author:" & oneNewClass.Author & "
" Response.Write "Version:" & oneNewClass.Version & "
"
Onenewclass.sexample = "This is an example of a simple class"
Response.write "User Custom:" & OnenewClass.example & "
"
Onenewclass.information
Set onnenewclass = Nothing
%>