SubItem(lIndex As Long) As Variable


lIndex As Long
Position of the element in the array or structure.
read only


With this method you get array and structure elements by index.


Sub SubItem()

Dim zVariables As Variables 'Object from type Variables
Dim zVariable As Variable 'Child object from type Variables
Dim cacheElement As Variable	'Child object from type Variables
Dim zEdLimit As EdLimit 'Object form type EdLimit
Dim zDrivers As Drivers 'Object from type Drivers
Dim zVarTypes As VarTypes 'Object from type VarTypes

'Fill the objects
Set zVariables = MyWorkspace.ActiveDocument.Variables
Set zDrivers = MyWorkspace.ActiveDocument.Drivers
Set zVarTypes = MyWorkspace.ActiveDocument.VarTypes

'Create a "intern driver" array variable called "array" from object type "internal variable", datatype "INT", start at index 1,
'dimension of 5 and automatic addressing
Set zVariable = zVariables.CreateArrayVar("array", zDrivers.Item(0), 33, zVarTypes.Item("INT"), 1, 5, 0, 0, True, False, False)

'Activate all array elements
For i = 0 To 4
	zVariable.ActivateSubItem (i)
Next i

'Read the first element from the array
Set cacheElement = zVariable.SubItem(0)
'Create a limit at the array element

'Select the first limit of the variable
Set zEdLimit = cacheElement.EDLimitItem(0)
'Set the limit active
zEdLimit.Active = True
'Set limit text
zEdLimit.Text = "Limit reached"
'Set limit value to 10
zEdLimit.LimitValue = 10
'Set the limit as maximum
zEdLimit.IsMax = True
'Set the limit as alarm
zEdLimit.Alarm = True
'Limit should be recognized in the CEL
zEdLimit.Cel = True

End Sub

See Also