STATEMENT:  Class

Implemented in version 5.0
 
Class ... End Class
 
The Class statement block is used to create a Class object. You can only create (name) one Class object with each Class statement. This ability to create your own Class is a significant expansion of the usefulness of the VBScript language.
 
Within the block of the Class statement you can declare the members of the class, which are variables, methods, and properties. Methods of the class are implemented by defining a Sub or Function procedure, while properties are defined through the use of Property Get, Property Let, and Property Set statements. Any member of a class may be declared as either Public or Private, with a Public declaration being the default state. Private members of a class are only accessible by other members of the same class, while Public members are accessible by anything, inside or outside of the scope of the class.
 
The Class statement must always end with an End Class.
 
Example:
<%
Class DevGuruProducts

   ' Creating a private property using Get, Let, Set
   Private mstrName
   ' Get
   Public Property Get CustomerName()
      CustomerName = mstrName
   End Property
   ' Let
   Public Property Let CustomerName(strName)
      mstrName = strName
   End Property
   ' Set
   Public Property Set Guru(objGuru)
      Private mobjGuru
      Set mobjGuru = objGuru
   End Property

   ' Creating a private method using a function
   Private Function DevGuruProductName(intProduct)
      Select Case intProduct
      Case 1
         DevGuruProductName = "dgCharge"
      Case 2
         DevGuruProductName = "dgList"
      Case 3
         DevGuruProductName = "dgReport"
   End Function

End Class
%>


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