ArrayList: Item (set) |
Sets the element at the specified index.
Public Property Set Item( ByVal Index As Long, ByRef Value 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. |
The example demonstrates how to directly set a value in an ArrayList.
Private Sub Main() Dim List As New ArrayList Dim Item As Variant List.AddRange Array("My", "name", "is", "Earl") Debug.Print "Original list contents." PrintValues List Debug.Print List(2) = "isn't" Debug.Print "Updated list contents." PrintValues List End Sub Private Sub PrintValues(ByVal List As IEnumerable) Dim Value As Variant For Each Value In List Debug.Print Value & " "; Next Debug.Print End Sub ' The example produces the following output. ' Original list contents. ' My Name Is Earl ' ' Updated list contents. ' My name isn't Earl