SortedList: GetValueList |
Gets the values in a SortedList object.
Public Function GetValueList ( ) As IList
The returned IList object is a read-only view of the values of the SortedList object. Modifications made to the underlying SortedList are immediately reflected in the IList.
The elements of the returned IList are sorted in the same order as the values of the SortedList.
This method is similar to the Values property, but returns an IList object instead of an ICollection object.
The following code example shows how to get one or all the keys or values in a SortedList object.
Public Sub Main() Dim List As New SortedList Dim KeyList As IList Dim ValueList As IList Dim Index As Long Dim i As Long List.Add 1.3, "fox" List.Add 1.4, "jumped" List.Add 1.5, "over" List.Add 1.2, "brown" List.Add 1.1, "quick" List.Add 1#, "The" List.Add 1.6, "the" List.Add 1.8, "dog" List.Add 1.7, "lazy" Index = 3 Debug.Print CorString.Format("The key at index {0} is {1}.", Index, List.GetKey(Index)) Debug.Print CorString.Format("The value at index {0} is {1}.", Index, List.GetByIndex(Index)) Set KeyList = List.GetKeyList Set ValueList = List.GetValueList Debug.Print , "Key", "Value" For i = 0 To List.Count - 1 Debug.Print , KeyList(i), ValueList(i) Next End Sub ' The code produces the following output. ' ' The key at index 3 is 1.3. ' The value at index 3 is fox. ' Key Value ' 1 The ' 1.1 quick ' 1.2 brown ' 1.3 fox ' 1.4 jumped ' 1.5 over ' 1.6 the ' 1.7 lazy ' 1.8 dog