Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











OBJECT:  Class

Implemented in 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.

The following example creates a simple Class, 'User', that has a single property, 'UserName', and one method, 'DisplayUserName'.

Code:
<%
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
%>

After you have declared your Class, then, as demonstrated below, you may create an instance of that Class (i.e., object) using Set and New.
 
Code:
<%
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
%>


Output:
"The Guru"

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information