小王设计了一个程序来列举仁川亚运会的奖牌前三的国家。下列VB程序实现如下功能:单击命令按钮Command1后,在列表框List1中按奖牌数由多到少显示国家名称,如图。
请根据算法将下列程序补充完整。
Dim a(1 To 45) As String
Dim b(1 To 45) As Integer
Private Sub Form_Load()
a(1) = "中国"
b(1) = 308
‘45个代表团名称及奖牌数分别放在a(1)到a(45)及b(1)到b(45)中
End Sub
Private Sub Command1_Click()
Dim i As Integer,j As Integer
Dim t As Integer,f As Integer
List1.Clear
For i = 1 To 3
For j = To 2 Step -1
If Then
f = a(j): a(j) = a(j - 1): a(j - 1) = f
t = b(j): b(j) = b(j - 1): b(j - 1) = t
End If
Next j
Next i
For i = 1 To 3
List1.AddItem "第" + Str(i) + "名" + a(i) + " 奖牌数" + Str(b(i))
Next i
End Sub