Select Case syntax and examples in ASP

Source: Internet
Author: User

When we make choice judgment, we usually use the IfElse method, but it is not suitable when the condition of judgment is more.
We usually use Select Case method to make choice judgment.
The SELECT statement allows a program to evaluate the expression and attempt to match the value of the expression to the case label.
If a match is found, the program executes the relevant declaration. The syntax for the SELECT statement is as follows:

The code is as follows Copy Code

<%
Select Case Expression
Case Label_1
Statements_1
Case Label_2
Statements_2
...
Case Else
Statements_n
End Select
%>

The plan first looks for the case of the value tag of the matching expression, and then the control shifts to the clause to execute the declaration of phase
. If a matching tag is not found, the program looks for the optional ELSE clause and, if found, controls the
transfer to the clause and executes the relevant declaration. If no case Else clause is found, the program continues to execute the declaration
after the selection ends. Use the rest time to avoid automatic execution by entering the next code.
Let's consider an example:

  code is as follows copy code

<%
Dim Flower
Flower = "Rose"
Select Case Flower
  case "Rose"
     Response.Write ( Flower & "Costs $2.50")
  case "Daisy"
     Response.Write (Flower & "costs $1.2 5 ")
  case" Orchild "
     Response.Write (Flower &" costs $1.50 ")
  case El Se
     Response.Write ("There is no such flower in my Own shop")
End Select
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.