急求……一道VB详解,满意加分!

来源:百度知道 编辑:UC知道 时间:2024/06/06 09:28:58
题目:设输入的数据分别为14,3,125,21时,标签框Label1.Caption的值分别是多少?
Private Sub Form Click()
Dim a As Integer
a=Val (InputBox (“请输入数据”,100))
Select Case a Mod 5
Case Is <4
w=a+10
Case Is<2
w=a*2
Case Else
w=a-10
End Select
Label1.Caption=“w=”& Str(w)
w= 4
w= 13
w= 135
w= 31
我想问,难道Case Is<2
w=a*2

这个语句在这里怎么就没有用了?(都套用第一个CASE IS<4,怎么回事啊?)

Select Case a Mod 5
Case Is <4
w=a+10
Case Is<2
w=a*2
Case Else
w=a-10
End Select
这里执行了Case Is <4 就不会再执行Case Is<2
所以就会出现这样的问题了,如果你想执行Case Is<2 这个语句的话你需要
把Case Is 2 to 4应该就可以了
你试试看吧

4 写下面

我看不懂.

就是说数已经小于4了 就没有执行小于2的必要了 你地, 明白?