maxim465
maxim465

Reputation: 195

The variable belongs to a range of values

I have this code:

If t=241 Then 

...

End if 

But if i want the variable to be equal to the range of values ​​(241-540), how to write it?

Upvotes: 1

Views: 52

Answers (2)

Vincent G
Vincent G

Reputation: 3188

If your condition start to become more complicated, you might want to take a look at the 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

Upvotes: 1

Louis
Louis

Reputation: 3632

This is what you're looking for:

If t > 241 And t < 540 Then

'...

End if

Upvotes: 1

Related Questions