Page 1 of 1

combobox sort

Posted: Sun Aug 17, 2003 5:06 pm
by aldo
I use Intellicad 4 PE at work I am
a beginner VBA user and I would like to
know how can I sort itens in listbox or combobox e.g. A, b, c, not B , a, c,?

Thanks
Aldo

Posted: Mon Aug 18, 2003 9:18 am
by ssc
aldo,

Before adding items to the combobox load them in an array and call the following:

Private Sub BubbleSort(aRR() As String)

Dim i As Integer, j As Integer, Low As Integer, Hi As Integer, Temp As String
Low = LBound(aRR)
Hi = UBound(aRR)
For i = Low To Hi - 1
For j = i + 1 To Hi
If aRR(i) > aRR(j) Then
Temp = aRR(i)
aRR(i) = aRR(j)
aRR(j) = Temp
End If
Next j
Next i
End Sub

Then add the contents of the array to the combobox.

ssc