Classes

The ability to define a class naively in VBScript is a welcome addition to VBScript 5. Classes are a great way to organize your code for readability, maintainability, and resuability. A class is a self-contained unit of code that acts as a template for an object, Classes are the building blocks of components.

Since scripts are generally self-contained units (with all of the code that makes up a script embedded in a single text file), and since, in languages such as VB and C++, classes are defined in their own separate text files, the VBScript development team had a bit of a challenge to give VBScript developers the ability to define a class. They solved the problem with the Class statements, which allows you to define a class within a script. You define the properties and methods (public and private) for a class between class and End class statements. You can then instantiate this class into an object variable and use it just like any other object. Writing classes is very straightforward. If you've had any experience writing classes in Visual Basic, you won't have any trouble.

First
Next