Working with Collections

<< Click to Display Table of Contents >>

 

Working with Collections

A Collection is an object that manages a set of similar objects. The objects contained in a collection are referred by indexes, similarly to array references. Users can add or remove individual objects from a collection, as in the next example.

Sub CommandButton1_Click()
  ' Add a Pen to an E3Chart1 object
  Screen.Item("E3Chart1").Pens.AddPen "Pen"
End Sub
 
Sub CommandButton2_Click()
  ' Removes the first Pen
  Screen.Item("E3Chart1").Pens.Remove 0
End Sub

 

NOTE

The first object in a collection has an index of 1 (one).

 

All collections have a common property named Count, which is the number of existing objects or children, according to the next example.

Sub CommandButton1_Click()
  ' Shows a dialog box with the number of Pens
  MsgBox Screen.Item("E3Chart1").Pens.Count
End Sub

Was this page useful?