Dim xm(1 to 100)As String ,cj(1 to 100)As Integer
Dim flag(1 to 100)As Boolean
Private Sub Form_ Load()
‘从数据库中读取数据,存储到相应数组中,并输出在列表框List1。第i个人,姓名为xm(i),成绩为cj(i)。人员数量存储到变量n中(1≤n≤100)。代码略
End Sub
Private Sub Cmd__Click()
Dim min As Integer, pmin As Integer
min = cj(1): pmin = 1
For i=2 To n
If cj(i) < min Then min = cj(i):
Next i
flag(pmin) = True
pmin= pmin + 1
If pmin=n+1 Then pmin=1
For i=1 To n-2
k = pmin
For j=1 To n
If Then k= j
Next j
If k <> pmin Then
t = cj(k): cj(k) = cj(pmin): cj(pmin) = t
C = xm(k): xm(k) = xm(pmin): xm(pmin) = c
End If
flag(pmin) = True
pmin=pmin+1
Next i
’将排序后的人员姓名和成绩输出到列表框List2中,代码略。
End Sub