Results 1 to 3 of 3

Thread: Checking if a number is in a range [CLOSED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Location
    Wollongong. NSW. Australia
    Posts
    470

    Resolved 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:
    1. 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.

  2. #2
    Member PokeyDillard's Avatar
    Join Date
    Jul 2005
    Location
    beating my head against my desk in Indianapolis, IN
    Posts
    58

    Re: Checking if a number is in a range

    Try this:

    VB Code:
    1. Select Case Val(x)
    2.         Case 1 To 12, 31, 32, 35 To 45:
    3.             MsgBox "in range"
    4.         Case Else
    5.             MsgBox "not in range"
    6.     End Select
    "The greatest mistake you can make in life is to be continually fearing you will make one."
    -Elbert Hubbard

    Custom Colors on Disabled Controls

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Location
    Wollongong. NSW. Australia
    Posts
    470

    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
  •  



Click Here to Expand Forum to Full Width