|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
SortedList 类表示键/值对的集合,这些键值对按键排序并可按照键和索引访问。
功能自己体会
Sub test()
Dim objSortedList As Object
Dim objList2 As Object
Dim I As Integer
Set objSortedList = CreateObject("System.Collections.Sortedlist")
objSortedList.Add "First", "AAAA"
objSortedList.Add "Second", "!"
objSortedList.Add "Third", "CCCC"
objSortedList.Add "Fourth", ","
Debug.Print objSortedList.IndexOfKey("First")
Debug.Print objSortedList.IndexOfValue("AAAA")
Debug.Print objSortedList.IndexOfKey("Second")
Debug.Print objSortedList.IndexOfValue("!")
Debug.Print objSortedList.IndexOfKey("Third")
Debug.Print objSortedList.IndexOfValue("CCCC")
Debug.Print objSortedList.IndexOfKey("Fourth")
Debug.Print objSortedList.IndexOfValue(",")
For I = 0 To objSortedList.Count - 1
Debug.Print objSortedList.GetKey(I) & vbTab & objSortedList.GetByIndex(I)
Next
Debug.Print "Size : " & objSortedList.Count
Debug.Print "Capacity : " & objSortedList.Capacity
Debug.Print objSortedList.GetByIndex(objSortedList.IndexOfKey("Third"))
objSortedList.TrimToSize
Debug.Print "Size : " & objSortedList.Count
Debug.Print "Capacity : " & objSortedList.Capacity
Set objList2 = objSortedList.Clone
Debug.Print "Sorted List Key(1) = " & objSortedList.GetKey(1)
Debug.Print "Cloned List Key(1) = " & objList2.GetKey(1)
Set objList2 = Nothing
Set objSortedList = Nothing
End Sub
Sub 最喜欢的性能()
Dim O As Object
Set O = CreateObject("System.Collections.Sortedlist")
O.Add "张三", "80分"
O.Add "李四", "60分"
O.Add "王五", "90分"
O.Add "赵六", "20分"
MsgBox "王五分数是:" & vbTab & O.GetByIndex(O.IndexOfKey("王五"))
Set O = Nothing
End Sub
|
评分
-
1
查看全部评分
-
|