求帮助 为什么这个vb小程序只能在输入90以上的时候正确输出
PrivateSubCommand1_Click()DimsmathscoreAsStringsmathscore=InputBox("请输入您的数学成绩","成绩")I...
Private Sub Command1_Click()
Dim smathscore As String
smathscore = InputBox("请输入您的数学成绩", "成绩")
If 90 <= smathscore And smathscore <= 100 Then
MsgBox "优秀" & smathscore, vbOKOnly, "优秀"
If 80 <= smathscore And smathscore < 90 Then
MsgBox "良好" & smathscore, vbOKOnly, "良好"
If 70 <= smathscore And smathscore < 80 Then
MsgBox "中等" & smathscore, vbOKOnly, "中等"
If 60 <= smathscore And smathscore < 70 Then
MsgBox "及格" & smathscore, vbOKOnly, "及格"
If 0 <= smathscore And smathscore < 60 Then
MsgBox "不及格" & smathscore, vbOKOnly, "不及格"
Else
MsgBox "error" & smathscore, vbOKOnly, "error"
End If
End If
End If
End If
End If
End Sub 展开
Dim smathscore As String
smathscore = InputBox("请输入您的数学成绩", "成绩")
If 90 <= smathscore And smathscore <= 100 Then
MsgBox "优秀" & smathscore, vbOKOnly, "优秀"
If 80 <= smathscore And smathscore < 90 Then
MsgBox "良好" & smathscore, vbOKOnly, "良好"
If 70 <= smathscore And smathscore < 80 Then
MsgBox "中等" & smathscore, vbOKOnly, "中等"
If 60 <= smathscore And smathscore < 70 Then
MsgBox "及格" & smathscore, vbOKOnly, "及格"
If 0 <= smathscore And smathscore < 60 Then
MsgBox "不及格" & smathscore, vbOKOnly, "不及格"
Else
MsgBox "error" & smathscore, vbOKOnly, "error"
End If
End If
End If
End If
End If
End Sub 展开
1个回答
展开全部
Dim smathscore As String
smathscore = InputBox("请输入您的数学成绩", "成绩")
If 90 <= smathscore And smathscore <= 100 Then
MsgBox("优秀" & smathscore, vbOKOnly, "优秀")
ElseIf 80 <= smathscore And smathscore < 90 Then
MsgBox("良好" & smathscore, vbOKOnly, "良好")
ElseIf 70 <= smathscore And smathscore < 80 Then
MsgBox("中等" & smathscore, vbOKOnly, "中等")
ElseIf 60 <= smathscore And smathscore < 70 Then
MsgBox("及格" & smathscore, vbOKOnly, "及格")
ElseIf 0 <= smathscore And smathscore < 60 Then
MsgBox("不及格" & smathscore, vbOKOnly, "不及格")
Else
MsgBox("error" & smathscore, vbOKOnly, "error")
End If
End Sub
你那个程序错的地方在于,你的end if 用的不正确,例如你输入70,可是你的代码必须达到以下条件 If 90 <= smathscore And smathscore <= 100 Then 才能运行接下去的代码,所以你的程序只能在输入90以上的时候正确输出
smathscore = InputBox("请输入您的数学成绩", "成绩")
If 90 <= smathscore And smathscore <= 100 Then
MsgBox("优秀" & smathscore, vbOKOnly, "优秀")
ElseIf 80 <= smathscore And smathscore < 90 Then
MsgBox("良好" & smathscore, vbOKOnly, "良好")
ElseIf 70 <= smathscore And smathscore < 80 Then
MsgBox("中等" & smathscore, vbOKOnly, "中等")
ElseIf 60 <= smathscore And smathscore < 70 Then
MsgBox("及格" & smathscore, vbOKOnly, "及格")
ElseIf 0 <= smathscore And smathscore < 60 Then
MsgBox("不及格" & smathscore, vbOKOnly, "不及格")
Else
MsgBox("error" & smathscore, vbOKOnly, "error")
End If
End Sub
你那个程序错的地方在于,你的end if 用的不正确,例如你输入70,可是你的代码必须达到以下条件 If 90 <= smathscore And smathscore <= 100 Then 才能运行接下去的代码,所以你的程序只能在输入90以上的时候正确输出
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询