SortedList: Item (let)

Item

Sets the value associated with a specific key in a SortedList object.



 Public Property Let Item(
	  ByRef Key As Variant,
	  ByRef Value As Variant )

Parameters

Key
[ByRef] Variant. The key associated with the value to set.
Value
[ByRef] Variant. The value associated with the Key parameter in the SortedList object.

Remarks

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.

Exceptions

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.
InvalidOperationExceptionThe comparer throws an exception.

See Also

Project CorLib Overview

Class SortedList Overview

Add

Contains

ContainsKey