Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim score As Single, n As Integer, sum As Integer = 0
Dim c1 As Integer = 0, c2 As Integer = 0, c3 As Integer = 0, c4 As Integer = 0, c5 As Integer = 0
n = CInt(InputBox("输入几个人的成绩?"))
For i = 1 To n
score = Val(InputBox("输入第" & i & "个成绩:"))
If score < 60 Then
c5 += 1
ElseIf score < 70 Then
c4 += 1
ElseIf score < 80 Then
c3 += 1
ElseIf score < 90 Then
c2 += 1
ElseIf score <= 100 Then
c1 += 1
Else
MsgBox("输入有误")
i -= 1
End If
sum += score
Next
MessageBox.Show("不及格:" & c5 & vbCrLf & "及格:" & c4 & vbCrLf & "中等:" & c3 & vbCrLf & "良好:" & _
c2 & vbCrLf & "优秀:" & c1 & vbCrLf & vbCrLf & "平均分:" & Format(sum / n, "0.00") & vbCrLf & _
"筛淘滤:" & Format(c5 / n * 100, "0.00") & "%")
End Sub
温馨提示:答案为网友推荐,仅供参考