Private Sub Command1_Click()
Dim x As Long
Dim y As Long
x = Val(Text1.Text)Select Case x
Case x < 0
y = x + 1
Case 0 To 10 y = x * x - 5
Case x > 10
y = x * x * x
End Select
Text2.Text = Str(y)
End Sub
Dim x As Long
Dim y As Long
x = Val(Text1.Text)Select Case x
Case x < 0
y = x + 1
Case 0 To 10 y = x * x - 5
Case x > 10
y = x * x * x
End Select
Text2.Text = Str(y)
End Sub
case 0
case 1 to 10
case else
end select如果你将case 0改成case x<0 则将x<0作为整体判断,当x=0时,x<0的值为false,即为0,结束select,y=x+1...=1所以用的时候一定要注意,你可以用
if then
elseif then
else
end if语句代替这样的select语句
Dim x As Long
Dim y As Long
x = Val(Text1.Text)Select Case x
Case Is < 0
y = x + 1
Case 0 To 10 y = x * x - 5
Case Is > 10
y = x * x * x
End Select
Text2.Text = Str(y)
End Sub