SortedList: Item (get) |
Gets the value associated with a specific key in a SortedList object.
Public Property Get Item( ByRef Key As Variant ) As Variant
You can use the Item property to access a specific element in a collection by specifying the following syntax: myCollection(key)
.
You can also use this property to add new elements by setting the value of a key that does not exist in the SortedList object (for example, myCollection("myNonexistentKey") = myValue
).
However, if the specified key already exists in the SortedList, setting the Item property overwrites the old value.
In contrast, the Add method does not modify existing elements.
The elements of a SortedList are sorted by the keys either according to a specific IComparer implementation specified when the SortedList is created, or by the default Comparer.
Read/Write.
Exception | Condition |
---|---|
InvalidOperationException | The comparer throws an exception. |