The array in this example is called 'arr()' change it to your array name!
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim strFileName As String
'Sort
For i = 0 To UBound(arr()) - 1
For j = 0 To UBound(arr()) - 1 - i
If arr(j + 1) < arr(j) Then
strFileName = arr(j)
arr(j) = arr(j + 1)
arr(j + 1) = strFileName
End If
Next j
Next i
'Just to show the alphabetical list
List1.Clear 'Normal list .. Sorted = False
For j = 0 To UBound(arr())
List1.AddItem arr(j)
Next j
Look up Shell sort, Insertion Sort, Quick Sort, Bubble sort if you want the algorithms. If you want more detail, you need to be more specific in your question and let us know when the assignment is due.
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.