18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

Class<br />

Description Declares the name of a class, as well as a definition of the variables, properties, and methods<br />

that comprise the class<br />

Usage Class classname<br />

statements<br />

End Class<br />

Arguments classname<br />

Required. Name of the Class; follows standard variable naming conventions.<br />

statements<br />

Required. One or more statements that define the variables, properties, and methods of the<br />

Class.<br />

Remarks Within a Class block, members are declared as either Private or Public using the appropriate<br />

declaration statements. Anything declared as Private is visible only within the Class block.<br />

Anything declared as Public is visible within the Class block, as well as by code outside the<br />

Class block. Anything not explicitly declared as either Private or Public is Public by default.<br />

Procedures (either Sub or Function) declared Public within the class block become methods of<br />

the class. Public variables serve as properties of the class, as do properties explicitly declared<br />

using Property Get, Property Let, and Property Set. Default properties and methods <strong>for</strong> the<br />

class are specified in their declarations using the Default keyword. See the individual declaration<br />

statement topics <strong>for</strong> in<strong>for</strong>mation on how this keyword is used. You must instantiate an object to<br />

use it, using the Set command; i.e. Set objname = New classname<br />

See Also Property Get, Property Let, Property Set<br />

Example Class SignOn<br />

Private MyName, MyLevel ‘Variable declaration<br />

Public Property Let UsrName(strName) ‘Set the property value <strong>for</strong> user name<br />

MyName = strName<br />

End Property<br />

Public Property Let UsrLevel(strLevel) ‘Set the property value <strong>for</strong> user level<br />

MyLevel = strLevel<br />

End Property<br />

Public Property Get UsrName ‘Return the property value<br />

UsrName = MyName<br />

End Property<br />

Public Property Get UsrLevel ‘Return the property value<br />

UsrLevel = MyLevel<br />

End Property<br />

Public Sub LogOnMsg ‘LogOnMsg is a method. No parameters passed<br />

MsgBox MakeMsg(MyLevel)<br />

EndSub<br />

Private Function MakeMsg(strLevel)<br />

Select Case StrLevel<br />

Case “User”<br />

MakeMsg = “Hello “ & MyName & vbCrLf & “Logged on as “ & MyLevel<br />

Case “Supervisor”<br />

MakeMsg = “Welcome “ & MyName & vbCrLf & “Your level is “ & MyLevel<br />

End Select<br />

End Function<br />

End Class<br />

Dim LogOn<br />

Set LogOn = New SignOn ‘Instantiate the object<br />

With LogOn<br />

.UsrName = “Joe” ‘Set the name property<br />

.UsrLevel = “Supervisor” ‘Set the level property<br />

.LogOnMsg ‘Invoke logon method<br />

End With<br />

Set LogOn = Nothing<br />

<strong>InduSoft</strong>, Ltd. 173

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!