Const rs = 2500 '考生总人数(即记录总数)
Dim kh(1 To rs) As String, cj(0 To rs) As Integer
Dim xx(1 To 9) As String '数组xx存放学校名称,如xx(1)="柯中",xx(2)="鲁高"……数组下标代表该学校代码,即"柯中"代码是1,"鲁高"代码是2……
'从数据库中读取考号和成绩数据,存入kh和cj数组,并在list1中显示,代码略。
Private Sub Command1_Click()
Dim school As String, n As Integer, i As Integer, j As Integer
Dim t1 As Integer, t2 As String, flag As Boolean
xx(1) = "柯中": xx(2) = "鲁高": xx(3) = "越崎": xx(4) = "鉴湖"
xx(5) = "钱清": xx(6) = "豫才": xx(7) = "轻纺城": xx(8) = "鲁中"
For i = 1 To 8
If xx(i) = Text1.Text Then ①
Next i
n = Val(Text2.Text) : i = 1: flag = True
Do While flag
k = i
For j = i + 1 To rs
t = Val(Mid(kh(j), 1, 1))
If t = school Then
If ② Then k = j
End If
Next j
If i > n And cj(k) <> cj(i - 1) Then flag = False
If k <> i Then
t1 = cj(i): cj(i) = cj(k): cj(k) = t1
t2 = kh(i): kh(i) = kh(k): kh(k) = t2
End If
i = i + 1
Loop
List2.Clear
For j = 1 To ③
List2.AddItem kh(j) + " " + Str(cj(j))
Next j
End Sub
① ② ③