May 9 2008 5:54PM GMT
Posted by: Jerry Lees
vbscriptstatements, VBScript Statements, VBScript, Functions
VbScript Statements: Explaination of Select … Case
Posted by: Jerry Lees
The Select … Case Vbscript statement is a very powerful way to easily preform specific actions based on a comparison of a variable to a series of cases you specify, plus it allows for the fact that NONE of the cases apply with an optional case else condition. The Select Case statement is often a better solution then a if…Then…Else if when you have more than 2 conditions that could apply.
Consider the following code snippet to check if a number is positive or negative:
Function TestNumber(Number)
Select case Number
Case Number > 0
TestNumber = “Positive”
Case Number < 0
TestNumber = “Negative”
Case Else
TestNumber = “Zero”
End Select



You must be logged-in to post a comment. Log-in/Register