VBScript Tutorials - Herong's Tutorial Examples - Version 5.20, by Dr. Herong Yang

Class, Property, Method and Related Statements

This section describes general rules on creating your own classes in VBScript. A list of class related statements is provided.

Can you create your own class with VBScript? The answer is yes.

VBScript allows you to write a class with the following rules:

  • Use "Class class_name" statement to define a class.
  • Property members can be defined using class-level variables.
  • Property members can also be defined using "Property" procedures
  • Method members can be defined using function procedures and subroutine procedures
  • Class-level variables can be defined as "Private" for inside-class use only.
  • Procedure can be defined as "Private" for inside-class use only.
  • Initialization procedure can be defined for a new object.
  • Clean up procedure can be defined for a terminating object.

Things that you need to learn for creating your own classes:

  • "Class" Statement - Declares the name of a class and defines properties and methods that comprise the class.
  • "Property Let" Statement - Defines a property procedure to allow values, not objects, to be assigned to a property.
  • "Property Set" Statement - Defines a property procedure to allow objects, not values, to be assigned to a property.
  • "Property Get" Statement - Defines a property procedure to return values or objects of a property.
  • "Public" Statement - Declares variables to be used as public properties accessible inside and outside this class.
  • "Private" Statement - Declares variables to be used as private variables accessible only inside this class.
  • "Public" Qualifier - Declares procedures to be used as public methods accessible inside and outside this class.
  • "Private" Qualifier - Declares procedures to be used private procedures accessible only inside this class.
  • "Public Default" Qualifier - Declares a procedure to be the default public method accessible inside and outside this class.
  • "New" Operator - Instantiates an object from the specified class.
  • "Set" Statement - Assigns an object to a variable.
  • "Class_Initialize" Subroutine Procedure - Initializes a new object.
  • "Class_Terminate" Subroutine Procedure - Clears a terminating object.
  • "Nothing" Object - Releases the object reference of stored in the variable when assigned to a variable.

Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 Numeric Comparison Operations and Logical Operations

 String Operations - Concatenation and Comparison

 Variable Declaration and Assignment Statement

 Expression and Order of Operation Precedence

 Statement Syntax and Statement Types

 Array Data Type and Related Statements

 Array References and Array Assignment Statements

 Conditional Statements - "If ... Then" and "Select Case"

 Loop Statements - "For", "While", and "Do"

 "Function" and "Sub" Procedures

 Built-in Functions

 Inspecting Variables Received in Procedures

 Error Handling Flag and the "Err" Object

 Regular Expression Pattern Match and Replacement

 scrrun.dll - Scripting Runtime DLL Library

Creating Your Own Classes

Class, Property, Method and Related Statements

 "Class" Statement - Defining Your Own Class

 "New" Operator and "Nothing" Object

 "Public/Private" Variables and Dot Operator

 "Property Let/Set/Get" Procedures

 Object Methods - "Public" Procedures

 "New", "Set", "Is", ".", "Nothing" - Object Operations

 "StringBuffer" - A Class Example

 IE Web Browser Supporting VBScript

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)

 References

 Printable Copy - PDF Version

Class, Property, Method and Related Statements - Updated in 2015, by Dr. Herong Yang