The object OnlineVariable is a container for variables.
The method Define of this object requests all variables, that are linked to that object. The same thing happens whenever a picture is opened in the Runtime. On initializing the variable or changing the value an event is executed, in which the changed variable can be edited as a parameter.
This object should always be used, if one or more variable(s) are needed, that perhaps are not yet requested. As the request for the value of a variable takes most time, the performance here is increased, as you can be sure, that the values of the linked variables always are requested because of the method Define.
Hint: For the event the object Visual Basic has to be defined with the attribute WithEvents.
Using online variables always needs the following procedure:
· Linking the online variable to variables of the control system. For each variable the method Add has to be executed with the unique name of the variable. Alternatively you can also use the method AddBulk. In this case a dynamic string array is created, that contains the variables
Sub VariablesOfOLV() Dim i As Integer Dim obOLV As OnlineVariable Dim obVAR As Variable 'get OnlineVariable Set obOLV = thisProject.OnlineVariables.Item(0) Debug.Print "Active: " & obOLV.Aktiv 'enum linked variables For i = 0 To obOLV.Count - 1 Set obVAR = obOLV.Item(i) Debug.Print obVAR.Name & " - " & obVAR.Tagname Next i End Sub