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'.

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.
Dim objUser
Set objUser = New User

' set the UserName property
objUser.UserName = "The Guru"

' call the DisplayUserName method
' to print the user name

"The Guru"

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