ArrayList: Item (get) |
Gets the element at the specified index.
Public Property Get Item( ByVal Index As Long ) As Variant
ArrayList accepts allows duplicate elements.
This property provides the ability to access a specific element in the collection by using the following syntax: MyCollection(index)
.
ArrayList implements Item as the default property.
Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation.
Read/Write.
Exception | Condition |
---|---|
ArgumentOutOfRangeException |
Index is less than zero. -or- Index is equal to or greater than Count. |
This example demonstrates how to get an element from an ArrayList
Private Sub Main() Dim List As New ArrayList Dim Item As Variant List.AddRange Array("My", "name", "is", "Earl") Debug.Print "The list contains:" Debug.Print vbTab; List(0) Debug.Print vbTab; List(1) Debug.Print vbTab; List(2) Debug.Print vbTab; List(3) End Sub ' The example produces the following output. ' ' The list contains: ' My ' name ' is ' Earl