/ Published in: Visual Basic
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Public Sub SortNames() Dim Swapped As Boolean Dim J, I As Byte Dim tmpUser As UserType J = NumUsers - 1 Do J = J - 1 Swapped = False For I = 0 To J If User(I).Surname > User(I + 1).Surname Or _ (User(I).Surname = User(I + 1).Surname And _ User(I).Forename > User(I + 1).Forename) Then 'Out of order so swap Swapped = True tmpUser = User(I) User(I) = User(I + 1) User(I + 1) = tmpUser End If Next I Loop Until Swapped = False Or J = 1 End Sub