that has these properties as part of the interface can be called a collection. In VB, a collection can be iterated using either
The first method explicitly uses Count and Item to index the elements of the collection.
OPC Data Access Automation Specification2.02
For I = 1
To object.Count
element = object.Item ( I )
‘or…
element = object( I )
Next I
The second method iterates through the available items using the hidden _NewEnum function:
For Each element
In object
‘do something with element
Next element
The For Each method of iterating a collection is faster than the explicit Item method.
Item can also be used to access
a particular index, such as Item( 3 ). It doesn’t need to be used within a loop.
Do'stlaringiz bilan baham: