basically i had to write a program where a user enters the amount of countrys taking part in the Olympics and enters there medals. i should then be able to sort the country's out with the best country being the one with the most amount of gold meals. my problem is its not sorting it out and oping someone could help. i also have a problem where i automatically want the program t work out the total by it self and don't know where to put it.
thanks in advance

data Code:
  1. Public Class fmldn
  2.     Structure Olympicsinfo
  3.         Dim country As String
  4.         Dim gold As String
  5.         Dim silver As String
  6.         Dim bronze As String
  7.         Dim total As String
  8.     End Structure
  9.  
  10.     Dim Olympics() As Olympicsinfo
  11.     Dim N As Integer
  12.  
  13.     Private Sub btnenter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenter.Click
  14.         N = InputBox("Enter the number of Countrys")
  15.         ReDim Olympics(0 To N - 1)
  16.  
  17.         For I = 0 To N - 1
  18.             Olympics(I).country = InputBox("Enter the Country")
  19.             Olympics(I).gold = InputBox("Enter the Amount of Gold Medals")
  20.             Olympics(I).silver = InputBox("Enter the Amount of Silver Medals")
  21.             Olympics(I).bronze = InputBox("Enter the Amount of Bronze Medals")
  22.             Olympics(I).total = InputBox("Enter the Total Amount Of Medals")
  23.         Next
  24.  
  25.     End Sub
  26.  
  27.  
  28.     Private Sub Display()
  29.         DGVolympics.Rows.Clear()
  30.  
  31.         For I = 0 To N - 1
  32.             dgvolympics.Rows.Add(Olympics(I).country, Olympics(I).gold,
  33.             Olympics(I).silver, Olympics(I).bronze, Olympics(I).total)
  34.         Next
  35.     End Sub
  36.  
  37.     Private Sub btnview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnview.Click
  38.         Call Display()
  39.     End Sub
  40.  
  41.     Private Sub btnsort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsort.Click
  42.         Dim Swap As Boolean
  43.         Dim temp As Olympicsinfo
  44.         'Perform the Bubble Sort
  45.         Do
  46.             Swap = True
  47.             For I = 0 To N - 2
  48.                 If Olympics(I).gold > Olympics(I + 1).gold Then
  49.                     Swap = True
  50.                     temp = Olympics(I)
  51.                     Olympics(I) = Olympics(I + 1)
  52.                     Olympics(I + 1) = temp
  53.                 End If
  54.             Next I
  55.             N = N - 1
  56.         Loop Until (Not (Swap) Or (N = 1))
  57.     End Sub
  58.  
  59. End Class