In this recipe, you will learn the following:
The basic concepts and the syntax required by VBScript to implement a class
The different components of a class and interoperation
How to implement a type of generic constructor function for VBScript classes
How to use a class during runtime
From the File menu, navigate to New | Function Library…, or use the Alt + Shift + N shortcut. Name the new function library cls.MyFirstClass.vbs
and associate it with your test.
We will build our MyFirstClass
class from the ground up. There are several steps one must follow to implement a class; they are follows:
Define the class as follows:
Class MyFirstClass
Next, we define the class fields. Fields are like regular variables, but encapsulated within the namespace defined by the class. The fields can be private or public. A private field can be accessed only by class members. A public field can be accessed from any block of code. The code is as follows:
Class MyFirstClass...