First of all, the ASP (VBSCRIPT) class is composed of events and methods (they are members of a class). If you have n’t exposed to it, you can first look at the following instructions (haha, I am currently selling and selling. If it's not good, please forgive)
In the Class block, members are declared by the corresponding statement statement as Private (private members, can only be called inside in the class) or PUBLIC (public members, can be called inside and outside the class). The declared as Private will only be visible in the Class block. It is declared that Public is not only visible inside the Class block, but also visible to code other than Class blocks. The default is Public that did not use Private or Public to clearly stated. The process of being declared in the class block as Public will become a class method. Public variables will become the attributes of the class, as well as using the Property Get, Property Let, and Property Set. The default attributes and methods of the class are specified in the default keywords in their statement.
Please read the blue part inside, let's take a look at an example below
<script Language = VBScript Runat = Server>
Class MyClass
'// ---- Declaration (Declaration is definition) The internal (private [Private]) variables of the MyClass class
Private Strauthor
Private Strversion
Private Strexample
'// ------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------//
'// ---- class_initialize () is an initialization event of the class. As long as you use this class, you will first trigger the execution of this part. Below we will initialize the authors and versions of the class and display on the screen in the member. The category has begun
Private sub class_initialize ()
StrautHor = Siyuan
strversion = 1.0
response.write <br> MyClass started <br>
end sub
'// ---- class_terminate () is an end event of the class. As long as the class is exited, the event will be triggered. Below we will display the class in the event that will be displayed on the screen that this class is over. Essence
Private sub class_terminate ()
response.write <br> MyClass is over <br>
end sub
'// ------------------------------------------------------------------------------------------------------------------------------- ----------------//
'// ---- This method returns a version information
public sub information () ()
response.write <br> Coding by <A href = 'Mailto: [Email Protected]'> Maxid_zen </a> </ a>. <br>
end sub
'// --------------------------------------------------------------------------------------------------------------------------------------------- ----------------//
'// ---- The attribute of the fixed class, this attribute is to allow users
Public Property Let SETEXAPMLE (byval Strvar)
strexapmle = Strvar
End Property
'// --------------------------------------------------------------------------------------------------------------------------------------------- ----------------//
'// ---- Define the attributes of the class, this attribute is to return a version number
Public Property Get Version
Version = Strversion
End Property
'// ---- Define the attributes of the class, this attribute is the author number returned to this class
Public Property Get Author
Author = Strauthor
End Property
'// ---- Define the attributes of the class, this attribute is to return a version number
Public Property Get EXAPMLE
exapmle = strexapmle
End Property
end class
</script>
<%
'// ------- This is an example of using this class
DIM Onenewclass
set onenewclass = new myclass
response.write Author: & onenewclass.author & <br>
response.write version: & onenewclass.version & <br>
OnenewClass.Setexapmle = This is an example of a simple class
Response.write user customized: & Onenewclass.exapmle & <br>
Onenewclass.information
set onenewclass = Nothing
%>