SoFunction
Updated on 2025-04-09

Detailed description of ASP class writing

First of all, the ASP classes are composed of events and methods (they are members of the class). If you have not been exposed to them, you can first look at the instructions below (haha, I am learning and selling now, please forgive me if I don’t say it well)
In the Class block, members are declared as Private (private members, only called inside the class) or Public (public members, can be called 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 to code outside the Class block. Not explicitly declared using Private or Public is defaulted to Public. A procedure (Sub or Function) declared as Public inside a class's block will become a method of the class. Public variables will become properties of the class, the same as those explicitly declared using Property Get, Property Let, and Property Set. The default properties and methods of classes are specified with the Default keyword in their declaration section.
Please read the blue part in your heart, let’s take a look at an example below
<script language=vbscript runat=server>

Class myClass
'//----Declare (declaration is definition) the inner (private [Private]) variable of the myClass class
        Private strAuthor
        Private strVersion
        Private strExample

'//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'//----Class_Initialize() is the initialization event of the class. As long as you use this class at the beginning, the execution of this part will be triggered. Next, we will initialize the author and version of the class in the member and show on the screen that the class has started.

        Private Sub Class_Initialize()
strAuthor = Siyuan
                strVersion = 1.0
<br>myClass has begun<br>
        End Sub
'//----Class_Terminate() is the end event of the class. As soon as you exit the class, the event will be triggered. Below we will set the event in this event that the class has ended on the screen when exiting the class.

        Private Sub Class_Terminate()
<br>myClass is over<br>
        End Sub

'//-------------------------------------------------------------------------------------------------------------------------

'//----This method returns a version information

 Public Sub Information()
         <br>Coding By <a href='mailto:coder@'>Maxid_Zen</a> @ <a href='http://'></a>.<br>
 End Sub

'//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

'//------A property of the specified class, which allows the user to initialize the strExapmle variable

        Public Property Let setExapmle(ByVal strVar)
         strExapmle = strVar
 End Property

'//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

'//-----Define the attribute of the class, which returns a version number

 Public Property Get Version
  Version = strVersion
 End Property

'//-----Define the attribute of the class, which returns the author number of the class

 Public Property Get Author
  Author = strAuthor
 End Property

'//-----Define the attribute of the class, which returns a version number

 Public Property Get Exapmle
  Exapmle = strExapmle
 End Property

End Class

</script>
<%

'//------ Here is an example of using this class

Dim oneNewClass

Set oneNewClass = myClass

Author: & & <br>
Version: & & <br>

= This is an example of a simple class

User-defined: & & <br>

Set oneNewClass = Nothing

%>