First of all, the ASP class is composed of events and methods (they are members of the composition category). If you have n’t exposed to it, you can first look at the description below:
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 the attributes of 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 watch the above part patiently, let's look at an example below:
| The following is the code fragment: <% '// --------------------------------------------------------------------------------------------- ---------------------// 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 = "ColdStone" 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 copyright information Public sub information () () Response.write "<br> Coding by <a href = 'Mailto: [email protected]'> COLDSTONE </a> @ <a href = 'http: //www.flash8.net'> >. <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 %> <% '// ------- 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 a simple example" Response.write "User Custom:" & Onenewclass.exapmle & "<br>" Onenewclass.information Set onenewclass = Nothing %> |