Version: 5.0
The term, Class, refers to any object that you create using the
Class ... End Class statement. This ability to create your own
object and to perform operations upon it using any valid VBScript code,
represents a significant expansion of the versatility of the VBScript
language.
Note that Class is a keyword and you may not use it as a class
name.
<%
Class User
' declare private class variable
Private m_userName
' declare the property
Public Property Get UserName
UserName = m_userName
End Property
Public Property Let UserName (strUserName)
m_userName = strUserName
End Property
' declare and define the method
Sub DisplayUserName
Response.Write UserName
End Sub
End Class
%>This example creates a simple Class, 'User', that has a single property, 'UserName', and one method, 'DisplayUserName'.
<%
Dim objUser
Set objUser = New User
' set the UserName property
objUser.UserName = "The Guru"
' call the DisplayUserName method
' to print the user name
objUser.DisplayUserName
%>"The Guru"After you have declared your Class, then, as demonstrated here, you may create an instance of that Class (i.e., object) using Set and New.