这段VB代码该怎样修改才可以正常调试?来看看答案是怎样的

这是个根据分数给出评价的程序,代码如下:

Private Sub Command1_Click()

Dim a As Single

a = Val(Text1.Text)

If a > 100 Or a < 0 Then

MsgBox ("invalid!")

End If

If a = 100 Then

MsgBox ("terrific!")

End If

If 90 <= a < 100 Then

MsgBox ("good!")

End If

If 75 <= a < 90 Then

MsgBox ("Not bad")

End If

If 60 <= a < 75 Then

MsgBox ("you can be better!")

End If

If a < 60 Then

MsgBox ("come on")

End If

End Sub

运行后按确认对话框会乱跳,请问该如何解决(本人新手一枚),谢谢!

之前一个朋友的问题,我分享一下正确的代码。


计算机语言的表达式与数学表达式有区别的.如你的

If 90 <= a < 100 Then

正确的是

If 90 <= a and a< 100 Then

改好的程序

Private Sub Command1_Click()
Dim a As Single
a = Val(Text1.Text)
If a > 100 Or a < 0 Then
MsgBox ("invalid!")
End If
If a = 100 Then
MsgBox ("terrific!")
End If
If 90 <= a And a < 100 Then
MsgBox ("good!")
End If
If 75 <= a And a < 90 Then
MsgBox ("Not bad")
End If
If 60 <= a And a < 75 Then
MsgBox ("you can be better!")
End If
If a < 60 Then
MsgBox ("come on")
End If
End Sub

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值