求助修改程序。我已经很努力了,可还是不会。
编一VB应用程序。要求如下:⑴ 随机产生20个学生的VB程序设计课程的成绩,存入一维数组中,并显示结果;
⑵ 求这20个学生的最高分、最低分和平均分,并显示结果;
⑶ 统计各分数段人数,即0~59、60~69、70~79、80~89、90~100,并显示结果;
⑷ 编写可对一组数据进行排序的自定义函数或过程。调用该自定义函数或过程将分数按由高到低的次序排列并输出。
⑸ 窗体界面自行设计。
Private Sub Command1_Click()
Dim a(1 To 20) As Integer
For i = 1 To 20
a(i) = Int(Rnd * 101)
Next i
Dim s(5 To 9)
For i = 1 To 20
k = a(i) \ 10
Select Case k
Case 0 To 5
s(5) = s(5) + 1
Case 9 To 10
s(9) = s(9) + 1
Case 6 To 8
s(k) = s(k) + 1
End Select
Next i
For i = 5 To 9
If s(i) <> 0 Then Picture3.Print "s("; i; ")的人数有"; Format(s(i), "0"); "个"
Next i
End Sub
Private Sub Command2_Click()
Dim a(1 To 20) As Integer, i%
For i = 1 To 20
a(i) = Int(Rnd * 101)
Next i
Call PaiXu(a())
End Sub
Private Sub Form_Click()
Dim a(1 To 20) As Integer, i%, maxa%, mina%, avera!
For i = 1 To 20
a(i) = Int(Rnd * 101)
Next i
mina = a(1)
maxa = a(1)
avera = a(1)
For i = 2 To 20
If a(i) > maxa Then maxa = a(i)
If a(i) < mina Then mina = a(i)
avera = avera + a(i)
Next i
For i = 1 To 20
Picture1.Print a(i);
If i Mod 10 = 0 Then Picture1.Print
Next i
Picture2.Print "最高分"; maxa, "最低分"; mina, "平均分"; avera / 20
End Sub
Sub PaiXu(ByRef a() As Integer)
Dim iMax%, n%, i%, j%, t%
n = UBound(a)
For i = LBound(a) To n
iMax = i
For j = i + 1 To n
If a(j) > a(iMax) Then iMax = j
Next j
t = a(i)
a(i) = a(iMax)
a(iMax) = t
Next i
For i = LBound(a) To UBound(a)
Picture4.Print a(i);
If i Mod 5 = 0 Then Picture4.Print
Next
End Sub
每一小点要求都会一些,连起来就错了,怎么改?求助。