Keith™ 发表于 2007-9-5 13:42:30

嗯..我最近一直在VB工作..had'考虑到在VB和VBA中属性不同的事实…
让我看看我能想出什么

Keith™ 发表于 2007-9-10 09:59:09

谢谢
'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 (intBottomTempintBottom)
      intTopTemp = intTopTemp - 1
    Wend
   
    If intBottomTemparr(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
页: 1 [2]
查看完整版本: 如何对组合框排序?