用VB程序编写"确定成绩等级"源程序 5
1个回答
展开全部
新建一个 text1 和一个 command1,在 text1 里面输入成绩,按下 command1 后等级就显示在 command1 上。下面是代码:
Private Sub Command1_Click()
Command1.Caption = GetStep(Text1.Text)
End Sub
Function GetStep(Scores As String) As String
Dim Score As Integer
GetStep = "错误的分数"
On Error Resume Next
Score = Scores
If Not (Score = 0 And Scores = "0") Then Exit Function
If Score > 100 Or Score < 0 Then Exit Function
Select Case Score
Case Is < 60
GetStep = "不及格"
Case Is < 75
GetStep = "良好"
Case Is < 95
GetStep = "优秀"
Case Else
GetStep = "漂亮"
End Select
End Function
Private Sub Command1_Click()
Command1.Caption = GetStep(Text1.Text)
End Sub
Function GetStep(Scores As String) As String
Dim Score As Integer
GetStep = "错误的分数"
On Error Resume Next
Score = Scores
If Not (Score = 0 And Scores = "0") Then Exit Function
If Score > 100 Or Score < 0 Then Exit Function
Select Case Score
Case Is < 60
GetStep = "不及格"
Case Is < 75
GetStep = "良好"
Case Is < 95
GetStep = "优秀"
Case Else
GetStep = "漂亮"
End Select
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询