实现上述功能的VB程序如下,请在划线处填入合适代码。
Dim n As
Integer
Dim xm(1 To
n) As String
Dim xb(0 To
n) As String
Dim cj(0 To
n) As Integer
Private Sub
Form_Load()
'读取学生姓名、性别和成绩分别存 xm、xb 和 cj 数组,并在列表框 List1 中显示。
'学生人数存变量 n,代码略。
End Sub
Private Sub
Command1_Click()
Dim s As String, k As Single, m As Single,
mm As Integer
Dim c As Integer, p As Integer, i As
Integer, j As Integer
Dim t1 As String, t2 As Integer
s = Text1.Text
k =
Val(Text2.Text)
c = 0
For i = 1 To n
If xb(i) = s Then
Next i
m = c * k / 100
If m < 1 Then
mm = 1
Else
mm =
End If
i = 1
Do While i <= n
p = i
For j = i + 1 To n
If xb(j) = s Then
If
Then p = j
End If
Next j
If i <> p Then
t1 = xb(i): xb(i) = xb(p): xb(p) = t1
t2 = cj(i): cj(i) = cj(p): cj(p) = t2
End If
If i > mm And (xb(i) <> xb(i - 1) Or cj(i) <> cj(i - 1)) Then Exit Do
i = i + 1
Loop
For i = 1 To mm
List2.AddItem xm(i) + " " + xb(i) + " " + Str(cj(i))
Next i
End Sub