分别使用if语句和select语句编写一个成绩等级判定程序,[90,100]为优秀,[80,90)为良好,[70,80)为中,[

2024-11-24 16:37:32
推荐回答(1个)
回答1:

Private Sub Pro1()
Dim Score As Single
Score = InputBox(prompt, "输入成绩", 0)
Select Case Val(Score)
Case Is >= 90
MsgBox "优秀"
Case Is >= 80
MsgBox "良好"
Case Is >= 70
MsgBox "中等"
Case Is >= 60
MsgBox "及格"
Case Else
MsgBox "不及格"
End Select
End Sub

Private Sub Pro2()
Dim Score As Single
Score = InputBox(prompt, "输入成绩", 0)
If Val(Score) >= 90 Then
MsgBox "优秀"
Exit Sub
End If
If Val(Score) >= 80 Then
MsgBox "良好"
Exit Sub
End If
If Val(Score) >= 70 Then
MsgBox "中等"
Exit Sub
End If
If Val(Score) >= 60 Then
MsgBox "及格"
Exit Sub
End If
MsgBox "不及格"
End Sub