Matching options by using Select Case statement in ASPIn VBScript used in ASP, when we have to match a given variable with more number of possible values, it is better to use Select Case statement. Here the first possible matching value is checked and then the code gets executed.This Select Case type statement is very common in other scripting languages and they are known differently in different scripts. In php the equivalent statement is SWITCH. Let us start with the syntax of Select Case statement in ASP
Here is the code part in a simple example where a number is stored in a variable and then it is matched with different Cases inside a Select Case statement.
The output of the above line is 'It is equal to 150'
In the same line while checking for one value we can check for another value by separating it with a coma, like this .
If none of the value matches with the variable we have set then we can keep one default value for this by using Case Else. So in the code below the Case Else statement will be executed.
Here the Case Else part will be executed as all other cases will fail to match.
This article is written by plus2net.com team.
Be the first to post comment on this article : ![]() | ||
| ||