Use class in your asp)

Source: Internet
Author: User
Introduction
Author: http://www.aspcn.com; flying knife

One day before, when I read VBScript to solve a syntax problem, I accidentally found the following sentence:

Class statement

Declares the name of a class, as well as a definition of the variables, properties, and methods that comprise the class.

The translation is ......

Class Declaration

Declaring a class name is to define some variables, attributes, and methods to form a class.

This is true !!!? You can use classes in VBScript !?!? I wonder if it can be used in ASP !? In this way, I cannot write ASP files like objects.Program?! Just do it! Practice is the only criterion for testing truth. Do it yourself!

We often see descriptions of classes in other programming languages, such as PHP, VB, and C. This class description in VBScript. I heard it for the first time. Our daily work is website development, in this case, we have more or less experience, and we can also boast an "expert", so I will share what I know about this new stuff. Let's take a look at the following:CodeRight! (Window2000 iis5.0 passed the test)

<%
''Declares a class named aspcn.
Class aspcn
Private aspcn
''Initialization class
Private sub class_initialize
Aspcn = "aspcn is good! <Br>"
End sub
''Defines a function
Public Function doit ()
Doit = aspcn
End Function
''Defines a method
Public sub querystr (STAT)
Response. Write stat
End sub

End Class

Set hi_aspcn = new aspcn ''defines an aspcn object instance named hi_aspcn.
Response. Write hi_aspcn.doit
Varstr = "aspcn is cool! <Br> <font color = Red> http://www.aspcn.com <;/font> <br> welcome !!! "
Hi_aspcn.querystr varstr

%>

This is a very simple program. We declare a class named aspcn in it, and create a doit function and a querystr method. This program is very simple for everyone to understand. Its display is as follows:

Aspcn is good!
Aspcn is cool!
Http://www.aspcn.com
Welcome !!!

In the future, we will be able to write the programs we commonly use into a class, and then use them <! -- # Include file = "XXX. asp" --> to include the file. This provides us with a new space for developing programs! Like C, it's a bit natural.

BenArticleFrom http://www.aspcn.com; ASP Chinese network if you want to reprint please be sure to indicate the source, thank you

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.