<< Click to Display Table of Contents >>
Accessing Objects using the Item Method |
Every collection contains an Item method, which can be used to access any object within that collection. The Item method accepts an Item parameter, which can be a positive integer number or the name of an object to access within a collection. The next example adjusts the color of the second Pen of an E3Chart.
Sub CommandButton1_Click()
' Changes the color of the second pen
Screen.Item("E3Chart1").Pens.Item(2).Color = RGB(212, 208, 20)
End Sub
The same adjustment can be performed with the next example.
Sub CommandButton1_Click()
' Changes the color of a pen named "Pen2"
Screen.Item("E3Chart1").Pens.Item("Pen2").Color = RGB(212, 208, 20)
End Sub
The previous commands are equivalent, the first one indicating the index of a Pen within a collection and the second one indicating its name.