How to compile an ASP class

Source: Internet
Author: User

A few days ago, Buddha wrote the "ASP design mode". Some beginners or friends who have just been familiar with ASP may not understand it completely. I even compiled an ASP method, most of them are obtained from the Internet. Hope to help friends.
ASP design pattern (Author: Buddha Mountain ):
Dispbbs. asp? Boardid = 20 & id = 247879
First, ASP classes are composed of events and methods (they are members of the classes). If you have not touched them, you can first take a look at the following description:
In the class block, the Member is declared as private (Private member, which can only be called within the class) or public (Public Member, which can be called inside and outside the class) through the corresponding declaration statement ). Declared as private will only be visible within the class block. Declared as public is not only visible inside the class block, but also outside the class block. Code It is also visible. If private or public statements are not used, the default value is public. The process (sub or function) declared as public within the block of the class will become the method of the class. Public variables will become attributes of the class, the same as those explicitly declared using property get, property let, and property set. The default attributes and methods of classes are specified with the default keyword in their Declaration section.
Please read the above part with patience. Let's look at an example below:

<%
'// ---------------------------------- Start a class ---------------------------------//
Class myclass

'// ---- Declare (Declaration is defined) the internal (Private [private]) variable of the myclass class
Private strauthor
Private strversion
Private strexample
'// --------------------------- Define the class event -------------------------------//

'// ---- Class_initialize () is the class initialization event. If you use this class at the beginning, the execution of this part is triggered first, next we will initialize the author and version of the class in this Member and display on the screen that the class has started.
Private sub class_initialize ()
Strauthor = "Coldstone"
Strversion = "1.0"
Response. Write "<br> myclass started <br>"
End sub

'// ---- Class_terminate () is the end event of the class. Once the class is exited, the event is triggered, next we will set this event to exit this class, and it will show on the screen that this class has ended.
Private sub class_terminate ()
Response. Write "<br> myclass ended <br>"
End sub
'// --------------------------- User-defined method -------------------------------//
'// ---- This method returns a copyright information
Public sub information ()
Response. write "<br> coding by <a href = 'mailto: coldstone@falsh8.cn '> Coldstone </a> @ <a href = 'HTTP: // www.flash8.net '> flash bar </a>. <br>"
End sub
'// --------------------------- Define the output attribute of the class -------------------------------//
'// ---- Specifies the attributes of the class. This attribute allows the user to initialize the strexapmle variable.
Public property let setexapmle (byval strvar)
Strexapmle = strvar
End Property
'// --------------------------- Define the output attribute of the class -------------------------------//
'// ---- Defines the attributes of the class. This attribute returns a version number.
Public property get version
Version = strversion
End Property
'// ---- Defines the attributes of the class. This attribute is the author number of the class returned.
Public property get author
Author = strauthor
End Property
'// ---- Defines the attributes of the class. This attribute returns a version number.
Public property get exapmle
Exapmle = strexapmle
End Property

End Class
%> <%
'// ------- Here 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 "custom:" & onenewclass. exapmle & "<br>"
Onenewclass. Information
Set onenewclass = nothing
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.