谢谢
-
- 'fill MyArray
- For i = 1 To UBound(ComboBox1.List)
- MyArray(i) = ComboBox1.List(i)
- Next i
- QuickSort MyArray, LBound(MyArray), UBound(MyArray)
- ComboBox1.Clear
- 'use sorted array to refill ComboBox
- For i = 1 To UBound(MyArray)
- If MyArray(i) "" Then _
- ComboBox1.AddItem MyArray(i)
- Next i
-
- Private Sub QuickSort(strArray() As String, intBottom As Integer, intTop As Integer)
- Dim strPivot As String, strTemp As String
- Dim intBottomTemp As Integer, intTopTemp As Integer
- intBottomTemp = intBottom
- intTopTemp = intTop
- strPivot = strArray((intBottom + intTop) \ 2)
- While (intBottomTemp intBottom)
- intTopTemp = intTopTemp - 1
- Wend
-
- If intBottomTemp arr(Index + 1)) Xor descending Then
- ' if the items are not in order, swap them
- arr(Index) = arr(Index + 1)
- arr(Index + 1) = Value
- lastSwap = Index
- End If
- Next
- Loop While lastSwap
- End Sub
|