Tutorial by Examples

Class Car Private wheels_ Private distances_ ' Property getter Public Property Get Wheels() Wheels = wheels_ End Property ' Property setter Public Property Let Wheels(v) wheels_ = v End Property ' Parameterless Constructo...
' Initialize the object Dim myCar Set myCar = new Car ' Setting a property myCar.Wheels = 4 ' Getting a property value wscript.echo myCar.Wheels ' Using a subroutine in a class myCar.Drive 10 myCar.Drive 12 ' Using a function in a class wscript.echo myCar.GetTotalDistance() ' r...
' Making a factory with parameter to the class Public Function new_Car(wheels) Set new_Car = New Car new_Car.Wheels = wheels End Function ' Creating a car through a factory Dim semiTrailer Set semiTrailer = new_Car(18)
Class Car ... ' Parameterless Constructor Public Sub Class_Initialize() distances_ = Array(0) End Sub ' Default initialization method that can be invoked without ' explicitly using the method name. Public Default Function Init(wheels) wheels_ = ...
Dim classFile : classFile = "carClass.vbs" Dim fsObj : Set fsObj = CreateObject("Scripting.FileSystemObject") Dim vbsFile : Set vbsFile = fsObj.OpenTextFile(classFile, 1, False) Dim myFunctionsStr : myFunctionsStr = vbsFile.ReadAll vbsFile.Close Set vbsFile = Nothing Set fs...

Page 1 of 1