Results 1 to 6 of 6

Thread: Easy Select Case question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Thumbs up Easy Select Case question

    Ok, I haven't used this in awhile so I just need a little refreshing. How can I do the following?

    VB Code:
    1. Select Case txtPieces.text
    2.  
    3. Case is between 1 and 199
    4. 'do something
    5.  
    6. Case is between 200 and 400
    7. 'Do something else
    8.  
    9. etc.........
    10.  
    11. End Select

    any help appreciated.

  2. #2
    Addicted Member glyptar's Avatar
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    138
    select case takes the first case that applies, processes it, and goes to end select, so you can do

    VB Code:
    1. Select Case yourvariable
    2.     Case Is > 600
    3.         'do thingy
    4.     Case Is > 400
    5.         'do another thingy
    6.     Case Is > 200
    7.         'do yet another thingy
    8.     Case is > 0
    9.         'do something else
    10. End Select

    hope it helps
    Glyptar

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    i think you can do this also
    select case var
    case 1 to 100
    and i KNOW you can separate them with commas
    case 1, 2, 3
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4
    Addicted Member glyptar's Avatar
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    138
    using commas from 1 to 199 will be annoying to program though
    Glyptar

  5. #5
    Addicted Member glyptar's Avatar
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    138
    I quickly checked, and

    case x to y

    does work
    Glyptar

  6. #6
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Case 500 to System.Int32.MaxValue is handy to be aware of too.

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