How to use ASP.net Select Case Conditional statement

Source: Internet
Author: User

If testexpression matches any of the case expressionlist expressions

, execute the statement between this case clause and the next one, for the last

clause, the statement is executed between the clause and the end Select, and the control

The statement that is transferred after the end Select. such as testexpression and multiple

The expressionlist expression in the case clause matches, only the first match

The following statement is executed. Case Else is used to indicate that if the testexpression

No match was found between the expressionlist of any other case option, the

Line elsestatements. Although not necessary, it is best to put the case Else language

Sentence is placed in a Select case block to handle unforeseen testexpression values

。 If no case expressionlist matches testexpression and no

Case Else statement, the statement after the end Select continues to execute.

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 ("A")
Case "DDD"
Response.Write ("B")
Case Else
Response.Write ("C")
End Select
End Sub
</script>

</body>

Example Two

<%@ 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>

</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.