安徽华力集团李金鹏:VB编程(初级呀)

来源:百度文库 编辑:高校问答 时间:2024/05/04 06:24:02
输入一百个学生的成绩,然后统计判断,把85~100的学生数量的值在优秀中显示,60~84在合格中显示,60以下的在不合格中显示^
Private Sub Command1_Click()
Dim i As Integer, a() As Single
Dim j As Integer, b As Integer, c As Integer
For i = 1 To 10
a(i) = InputBox("输入成绩")
If i >= 85 Then j = i
If i < 84 And i >= 60 Then b = i
If i < 60 Then c = i
Next i
Label1(0).Caption = j
Label1(1).Caption = b
Label1(2).Caption = c
End Sub
帮忙看看呀
可不可以帮忙改改呀

Private Sub Command1_Click()
Dim i As Integer, a(100) As Single
Dim j As Integer, b As Integer, c As Integer
j=0
b=0
c=0
For i = 1 To 10
a(i) = InputBox("输入成绩")
If a(i) >= 85 Then
j =j+1
elseif a(i) < 84 And a(i) >= 60 Then
b = b+1
elseif a(i) < 60 Then
c = c+1
end if
Next i
Label1(0).Caption = j
Label1(1).Caption = b
Label1(2).Caption = c
End Sub
你的程序有问题,求个数应该一个一加
而且,你缺少end if结束判断,定义数组应该有范围

J,B,C都是一个变量,不是数组,只能存一个成绩,你用for循环输入数据,然后付给J,B,C.每次赋值后又不把数据转移,第二次循环赋值时,第一次的数据就被第二次的值覆盖啦,有点类似小学里学的猴子摘玉米,所以最后只能得到最后一次的赋值,你这里循环10次,就是第10个学生的成绩,付给label了

Private Sub Command1_Click()
Dim i As Integer, a(10) As Single
Dim j As Integer, b As Integer, c As Integer
For i = 1 To 10
a(i) = InputBox("输入成绩")
If i >= 85 Then j = i
If i < 84 Then b = i
If i < 60 Then c = i
end if
end if
end if
Next i
Label1(0).Caption = j
Label1(1).Caption = b
Label1(2).Caption = c
End Sub