|
-
Jul 8th, 2005, 06:22 AM
#1
Thread Starter
Hyperactive Member
Checking if a number is in a range [CLOSED]
G'day,
I need to see if a variable is within certain ranges, but I can't remember how to do it.
VB Code:
If not x in [1 .. 12, 31, 32, 35 .. 45] then
Peter
Last edited by Supremus; Jul 8th, 2005 at 04:49 PM.
My reputation is in tatters. Don't bother trying to repair it.
-
Jul 8th, 2005, 07:21 AM
#2
Member
Re: Checking if a number is in a range
Try this:
VB Code:
Select Case Val(x)
Case 1 To 12, 31, 32, 35 To 45:
MsgBox "in range"
Case Else
MsgBox "not in range"
End Select
-
Jul 8th, 2005, 04:48 PM
#3
Thread Starter
Hyperactive Member
Re: Checking if a number is in a range
G'day Pokey,
Thanks for that. For some unknown reason, I thought I could do it as a single statement, but whilst lying in bed last night I started to have doubts and realised I would have to use the select statement.
Peter
My reputation is in tatters. Don't bother trying to repair it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|