(2)
请在划线处填入合适的代码
Dim xh(0 To 100) As String .
Dim cj(0 To 100) As Integer
Const num = 50
Private Sub Form_ Load ()
‘本过程从数据库读取每位学生的学号和成绩存放在数组xh和cj中,代码略
End Sub
Private Sub Com1_Click ()
Dim i
As Integer, m As Integer, n As Integer, k As Integer, a As Integ
a =
Val(Text1.Text)
For
i=1 To num-1
k=
If
k<>i Then
t=cj(k):cj(k)=cj(i):cj(i)=t
s=xh(k):xh(k)=xh(i):xh(i)=s
End If
Next i
m=a-1:n=a+1
Do
While cj(m) = cj(a)
m=m-1
Loop
Do
While cj(n) = cj(a)
n=n+1
Loop
If
m<>0 And Then lq = m Else lq=n-1
Label5.Caption
= Str(lq)
Label6.Caption
= Str(cj(lq))
List1.AddItem “字号”+“学号”+“成绩”
For
i=1 To lq
List1.AddItem Str(i) +“ ”+xh(i)+Str(cj(i))
Next i
End Sub
Function imax(x As Integer, y As Integer) As Integer
Dim i As Integer,j As Integer
i=x
For
j=x+1 To y
If Then i=j
Next j
imax =
i
End Function