• Home
  • Billiards
  • Classic ASP
  • Browse Blog
    • Halifax
    • Internet
    • Internet Marketing
    • Programming
    • SEO
    • Skateboarding
    • technology
    • travel
    • Uncategorized
    • Web Development
    • Web Hosting
    • Website Management
    • wedding
  • Subscribe via RSS

vbscript Select Case for Range of Values

December 23rd, 2008  |  Published in Web Development  |  4 Comments




Here is a snippet of vbscript I use in ASP and/or VBS applications where I need a select case statement for a range of values for each case. There isn’t too much documentation online about this, and it’s a bit of a hack, but this will do the trick.

1
2
3
4
5
6
7
8
select case TRUE
     case your_var >= 0 and your_var < = 4
         'do your stuff
     case your_var >= 5 and your_var < = 10
         'do your stuff
     case else
         'handle the else
end select

Basically, it tells the vbscript engine to select the case that evaluates to TRUE (or you could set to false, or any other value, such as “select case 199″ where it would choose the case whose statement evaluated to 199, depending on your requirements)

I know this is a bit of a hack but hey, classic asp is not as robust as some other languages, and so we have to inprovise. one other note, my example has values hardcoded into the select case statements. This is poor programming practice, and was only used for simplicity’s sake in demonstrating how the vbscript select case for a range of values statement works.

Comments welcome.

Responses

Feed Trackback Address
  1. Anon says:

    January 14th, 2009 at 12:17 pm (#)

    Like it!

  2. Anthony says:

    February 26th, 2009 at 11:54 am (#)

    Thanks for the information. You’ve saved me tons of time.

  3. jp says:

    July 6th, 2009 at 4:05 pm (#)

    Very nice!!!

  4. Tofudisan says:

    February 23rd, 2010 at 8:44 pm (#)

    Sweet! Been trying to get this to work. Had the “>= AND >=” condition worked out but couldn’t figure out why it wasn’t working. Then I found your post and see that I needed “select case TRUE”. D’OH! I had “select case avgSkill”.

    It works now though! Thanks!

Leave a Response

Tags

1and1 adsense asp Camping caribbean crowdsourcing CTR cuba Cueva de Pirata customer service dominican republic forum management godaddy google Halifax hosting hotel ideagora Internet Linux MySQL objWmiService outsourcing php Pirates Cave plugin scam scripts SEO server Skateboarding travel Varadero vbs vbscript web browser wedding What is Crowdsourcing? wi-fi wikipedia windows windows scripting winmgmts wireless internet xp

Pages

  • About Robar’s Pages
    • Privacy Policy for robarspages.ca
  • Classic ASP Programming and Development
  • Gran Bahia Principe Wedding
  • YouTube Extension Plugins for WordPress

Categories

  • Halifax
  • Internet
  • Internet Marketing
  • Programming
  • SEO
  • Skateboarding
  • technology
  • travel
  • Uncategorized
  • Web Development
  • Web Hosting
  • Website Management
  • wedding

Recent Posts

  • MySQL Statement List and MySQL Clause List
  • MySql Command Line Syntax
  • Ripoff Alert – Domain Registry of Canada Scam
  • 1&1 Scam Ripoff – Unlimited Traffic Promotion from 1 and 1
  • Improving Adsense CTR in Forum Pages

Recent Comments

  • admin on 1and1 Corporate Headquarters Phone Number
  • Mike Kay on 1and1 Corporate Headquarters Phone Number
  • Ed Wolfrum on 1and1 Corporate Headquarters Phone Number
  • Claire on Our Online Wedding Guestbook
  • Claire on Our Online Wedding Guestbook
©2010 Robar's Pages