Share via


VarSet.get Method

Gets a variable value from the VarSet object.

 VarSet.get(VariableName String)

Parameters

  • VariableName
    Specifies the name of the value to retrieve from the VarSet object.

Return Value

Variant

Examples

The following example shows how to use a VarSet object to store data between script sessions.

Function IncrementCriticalErrors()
    Const ERROR_VARSET_NAME = "Error Tracker"
    Const NORMAL_ERROR_COUNT = "Number of Errors"
    Const CRITICAL_ERROR_COUNT = "Number of Critical Errors"

    Dim objScriptState
    Dim objErrorVarSet
    Dim vntCriticalErrors

    Set objScriptState = ScriptContext.GetScriptState()
    Set objErrorVarSet = objScriptState.GetSet(ERROR_VARSET_NAME)

    ' get and modify count values
    vntCriticalErrors = objErrorVarSet.get(CRITICAL_ERROR_COUNT)
    vntCriticalErrors = CLng(vntCriticalErrors) + 1

    ' save variable changes back to the VarSet
    Call objErrorVarSet.put(CRITICAL_ERROR_COUNT, vntCriticalErrors)

    ' save the VarSet
    Call objScriptState.SaveSet(ERROR_VARSET_NAME, objErrorVarSet)

    Set objErrorVarSet = Nothing
    Set objScriptState = Nothing

    IncrementCriticalErrors = CLng(vntCriticalErrors)
End Function

Requirements

Platforms: Requires Windows 2000 or later

Version: Requires MOM 2000  or later

See Also

VarSet Object | VarSet.put Method