How to Use asp.net select Case condition statements

Source: Internet
Author: User

If testexpression matches any Case expressionlist expression

, The statement between this Case clause and the next Case clause is executed.

The statement between the clause and End Select is executed, and then the control

It will be converted to the statement after End Select. For example, testexpression and multiple

The expressionlist expression in the Case clause matches only the first expression.

The statement is executed. Case Else is used to indicate that

And expressionlist of any other Case options.

Line elsestatements. Although not necessary, it is best to use Case Else

The statement is placed in the Select Case block to process unpredictable testexpression values.

. If no Case expressionlist matches testexpression and no

Case Else statement, continue to execute the statement after End Select.

Select Case testexpression [Case expressionlist-n

[Statements-n]... [Case Else expressionlist-n

[Elsestatements-n] End Select

<% @ Page Language = "VB" %>

<Script runat = "server">
Sub Page_Load (Sender as object, e as eventargs)
Dim strClockStatus As String
StrClockStatus = "AAA"

Select Case strClockStatus
Case "AAA", "BBB", "CCC"
Response. Write ("")
Case "DDD"
Response. Write ("B ")
Case else
Response. Write ("C ")
End select
End sub
</Script>

<Html> <body>

</Body>

Instance 2

<% @ Page Language = "VB" %>

<Script runat = "server">
Sub Page_Load (Sender as object, e as eventargs)
Dim intAge As integer = 7

Select Case intAge
Case "7"
Response. Write ("That's a string! ")
Case 7
Response. Write ("7 ")
Case <10
Response. Write ("less than 10 ")
End select

End sub
</Script>

<Html> <body>

</Body>

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.