我有此代码:
If t=241 Then
...
End if
但是如果我希望变量等于值范围(241-540),怎么写呢?
答案 0 :(得分:1)
这是您要寻找的:
If t > 241 And t < 540 Then
'...
End if
答案 1 :(得分:1)
如果您的情况开始变得更加复杂,则可能需要看看Select Case statement:
Select Case t
Case 241 To 540, 620 To 728
'Code executed for values to t between 241 and 540, or between 620 and 728
'similar to If (t >= 241 And t <= 540) Or (t >=620 And t <= 728) Then
Case 800
'Code executed if t=800
Case Else
'Other case
End Select