SortedList: Item (get)

Item

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



 Public Property Get Item(
	  ByRef Key As Variant ) As Variant

Parameters

Key
[ByRef] Variant. The key associated with the value to get.

Return Values

Variant -  The value associated with the Key parameter in the SortedList object, if key is found; otherwise, Empty.

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

See Also

Project CorLib Overview

Class SortedList Overview

Add

Contains

ContainsKey