设计一简单VB,根据用户输入的成绩分数(百分制),判定成绩等级。判定按钮实现等级的判定, 【接下行】

清除按钮实现清除分数及结果,退出按钮实现结束功能。
等级判定标准为:
0-59分为不及格
60-74分为及格
75-89分为良好
90-90分为优秀

'加入3个command、2个label、1个text控件,位置自己调整一下
Option Explicit
Private Sub Command1_Click()
If IsNumeric(Text1) Then '是否为数字
If Val(Text1) >= 0 And Val(Text1) <= 100 Then '分数范围0-100
If Val(Text1) < 60 Then
Label2 = "结果:" & "不及格"
ElseIf Val(Text1) < 75 Then
Label2 = "结果:" & "及格"
ElseIf Val(Text1) < 90 Then
Label2 = "结果:" & "良好"
Else
Label2 = "结果:" & "优秀"
End If
Else
Label2 = "结果:" & "无效的分数"
End If
Else
Label2 = "结果:" & "无效的数字"
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
Label2 = "结果:"
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Label1 = "分数:"
Text1 = ""
Label2 = "结果:"
Command1.Caption = "判定"
Command2.Caption = "清除"
Command3.Caption = "退出"
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-05-17
窗体上一共有三个command (1指“判定”按钮,2指“清除”按钮,3指"结束"按钮);两个文本框(1是输入成绩的,2是判别的)
Private Sub Command1_Click()
Dim a As Integer
a =Val(Text1.Text)
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
(上面的后三行代码是选中文本框1,如果不需要可以删除)
Select Case a
Case 90 To 100
Text2.Text = "优秀"
Case 75 To 89
Text2.Text = "良好"
Case 60 To 74
Text2.Text = "及格"
Case Is < 60
Text2.Text = "不及格"
End Select

If a < 0 Or a > 100 Then
MsgBox "输入错误,请重新输入"
End If
(这里的后三行是提示,如果输入负数或者大于100的数,显示输入错误,不需要可删除)
End Sub
Private Sub Command2_Click()
Text1.Cls
Text2.Cls
End Sub
Private Sub Command3_Click()
end
end sub