• 1. London, UK
  • 2. Sydney, Australia
  • 3. New York, NY
  • 4. Melbourne, Australia
  • 5. Paris, France
  • 6. San Francisco, CA
  • 7. Chicago, IL
  • 8. Moscow, Russia
  • 9. Amsterdam, The Netherlands
  • 10. Toronto, Canada

Monday, September 20, 2004

 

VBScript | SELECT CASE statement

Posted by Bharat Suneja at 3:06 PM
Rather than using too many IF-THEN conditions to check a value and take action, you are better off using the SELECT CASE condition. It produces cleaner code and is specifically meant for multiple IF-THEN conditions.

The correct use of SELECT CASE:

Select Case strValue [strValue is the variable you want to evaluate]
Case "John"...
do someting here if strValue = "John"
Case "Paul"...
do someting here if strValue = "Paul"
Case Else... [Unlike IF-THEN-ELSE, Select Case has CASE ELSE as the "catch-all"]
do this if strValue does not = "John" or "Paul"
End Select [END SELECT ends the Select Case loop, like END IF for IF-THEN]


Labels:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home