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

vbscript Select Case for Range of Values

December 23rd, 2008  |  Published in Web Development  |  6 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

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!

  5. Arthur Morgan says:

    September 19th, 2011 at 5:11 pm (#)

    MOST helpful–many thanks!

  6. Lim says:

    May 2nd, 2012 at 6:35 am (#)

    Thank you very much! Great tips!

Leave a Response

Tags

1and1 adsense asp caribbean classic asp crowdsourcing CTR cuba Cueva de Pirata customer service database dominican republic forum management godaddy google Halifax hosting hotel ideagora Internet Linux MySQL objWmiService outsourcing php Pirates Cave plugin scripting scripts SEO Skateboarding sql travel Varadero vbs vbscript web browser web development wedding What is Crowdsourcing? wikipedia windows windows scripting winmgmts 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

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

Recent Posts

  • HTTP_X_EAC_REQUEST
  • eZooms Bot User Agent
  • SQL Full Outer Join Three Tables
  • Classic ASP Data Caching for Performance
  • Comparing OLE DB and ODBC Connections

Recent Comments

  • AP on 1and1 Corporate Headquarters Phone Number
  • AJ on 1and1 Corporate Headquarters Phone Number
  • cordova on 1and1 Corporate Headquarters Phone Number
  • mike on 1and1 Corporate Headquarters Phone Number
  • David on Regex MM/YYYY Regular Expression for Credit Card Expiration Date
©2022 Robar's Pages
Sitemap and Table Of Contents