Variables method (WinStudio scripts)

Applies To

  • IWSApplication interface
  • IWSForm interface

Definition

Returns a Visual Basic object that references a form-level or global variable; or sets a form-level or global variable.

Get Syntax

varObject = object.Variables( string )

  Part   Description
varObject Required. A Visual Basic variable that is defined as an object and that references the form or the IWSApplication interface.
object Required. For a form-level variable, reference to a valid form object. For a global variable, use Application.
string Required. The name of the variable.

Set Syntax

object.Variables( string ) = varObject

  Part   Description
object Required. For a form-level variable, reference to a valid form object. For a global variable, use Application.
string Required. The name of the variable.
varObject Required. A Visual Basic variable that is defined as an object and that references the form or the IWSApplication interface.

Remarks

In the Get Syntax, the Visual Basic Set instruction assigns an object reference to a variable.

Example: Global Variables

Sub Main()
   Dim strFormPersVar As String
   Dim strFormTempVar As String
   Dim strGlobalPersVar As String
   ' Persistent Form level variable
   strFormPersVar = ThisForm.Variables("InitialCommand").Value
   Application.ShowMessage(CStr(strFormPersVar) )
   ' This Set command creates a temporary variable on the current form
   ThisForm.Variables("NewTempVar").Value = "TestValue"
   strFormTempVar = ThisForm.Variables("NewTempVar").Value
   Application.ShowMessage( "Name = " & "NewTempVar" & _
      " Value = " & CStr(strFormTempVar) )
   ' Persistent Global variable
   strGlobalPersVar = Application.Variables("BatchNoVL").Value
   Application.ShowMessage(CStr(strGlobalPersVar) )
End Sub

Example: Form Variables

Sub Main()
     Dim oVarParticular As IWSVariable
     ' Set a VB variable to a particular Form variable
     oVarParticular = ThisForm.Variables( "TestVar" )
     Application.ShowMessage("TestVar" & oVarParticular.Value & vbLf & _
        "TestVar2" & oVarParticular.Value)
End Sub