Option Explicit
Private Type League
Team As String
Played As Integer
Won As Integer
Drawn As Integer
Lost As Integer
Points As Integer
End Type
Private Sub Form_Load() ' You wouldn't do this in Form_Load
Dim LeageTable(18) As League
Dim Temp As League
Dim lngIndex As Long
Dim bSwapped As Boolean
'Add some test data (I know the values don't make sense)
LeageTable(0).Team = "Arsenal"
LeageTable(0).Played = 0
LeageTable(0).Won = 0
LeageTable(0).Lost = 0
LeageTable(0).Drawn = 0
LeageTable(0).Points = 3
LeageTable(1).Team = "Liverpool"
LeageTable(1).Played = 0
LeageTable(1).Won = 0
LeageTable(1).Lost = 0
LeageTable(1).Drawn = 0
LeageTable(1).Points = 5
LeageTable(2).Team = "Tottenham"
LeageTable(2).Played = 0
LeageTable(2).Won = 0
LeageTable(2).Lost = 0
LeageTable(2).Drawn = 0
LeageTable(2).Points = 2
LeageTable(3).Team = "Man Utd"
LeageTable(3).Played = 0
LeageTable(3).Won = 0
LeageTable(3).Lost = 0
LeageTable(3).Drawn = 0
LeageTable(3).Points = 1
'sort the data
bSwapped = True
Do Until bSwapped = False
bSwapped = False
For lngIndex = 0 To 2 ' you would use 17
If LeageTable(lngIndex).Points <= LeageTable(lngIndex + 1).Points Then
' store the lower value data to be replaced
Temp.Drawn = LeageTable(lngIndex).Drawn
Temp.Lost = LeageTable(lngIndex).Lost
Temp.Played = LeageTable(lngIndex).Played
Temp.Points = LeageTable(lngIndex).Points
Temp.Team = LeageTable(lngIndex).Team
Temp.Won = LeageTable(lngIndex).Won
' move the higher values up one in the array
LeageTable(lngIndex).Drawn = LeageTable(lngIndex + 1).Drawn
LeageTable(lngIndex).Lost = LeageTable(lngIndex + 1).Lost
LeageTable(lngIndex).Played = LeageTable(lngIndex + 1).Played
LeageTable(lngIndex).Points = LeageTable(lngIndex + 1).Points
LeageTable(lngIndex).Team = LeageTable(lngIndex + 1).Team
LeageTable(lngIndex).Won = LeageTable(lngIndex + 1).Won
' replace the old higher value data with the saved lower values
LeageTable(lngIndex + 1).Drawn = Temp.Drawn
LeageTable(lngIndex + 1).Lost = Temp.Lost
LeageTable(lngIndex + 1).Played = Temp.Played
LeageTable(lngIndex + 1).Points = Temp.Points
LeageTable(lngIndex + 1).Team = Temp.Team
LeageTable(lngIndex + 1).Won = Temp.Won
bSwapped = True
End If
Next
Loop
' The array is now sorted with the highest point teams at the top and you
' can print that data to the picture.
End Sub