Const m = 6
Const n = 8
Dim a(1 To m * n) As String '存储学号
Dim b(1 To m * n) As Integer '存储身高
Dim num As Integer '班级总人数
Private Sub Command1_Click( )
'从数据库中读取该班的学号和身高数据存入数组a和数组b,班级人数存入变量num,代码略
'以下代码为在列表框List1中输出数据
s = "" : List1.AddItem " ( 讲 台 )"
For i = 1 To num
s = s & Str(b(i)) & "[" & a(i) & "] "
If Then
List1.AddItem s : s = ""
End If
Next i
If s <> "" Then List1.AddItem s
End Sub
Private Sub Command2_Click( )
Dim i As Integer, j As Integer, imin As Integer
Dim t1 As String, t2 As Integer, s As String
List2.AddItem " ( 讲 台 ) "
For i = 1 To
s = ""
For j = (i - 1) * n + 1 To (i - 1) * n + n
If j <= num Then
If imin <> j Then
t1 = a(imin): a(imin) = a(j): a(j) = t1
t2 = b(imin): b(imin) = b(j): b(j) = t2
End If
s = s & Str(b(j)) & "[" & a(j) & "] "
End If
Next j
List2.AddItem s
Next i
End Sub
Function fPos(p As Integer) As Integer
Dim i As Integer, j As Integer, k As Integer
k = p
For i =
If b(i) < b(k) Then k = i
Next i
fPos = k
End Function