| SortedList: Item (set) |
Sets the value associated with a specific key in a SortedList object.
Public Property Set Item( ByRef Key As Variant, ByRef Value 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 |
|---|---|
| NotSupportedException |
The property is set and the SortedList object is read-only. -or- The property is set, Key does not exist in the collection, and the SortedList has a fixed size. |
| InvalidOperationException | The comparer throws an exception. |