Vb. NET Learning Notes (conditional statement)

Source: Internet
Author: User
Tags case statement expression
Notes | condition | statement conditional statement
Vb. NET conditional statement is still an if then statement and a SELECR case statement.



If then statement
The If then statement is simpler and is the same as the original rule.



Examples of If conditional statements

Public Class Testa

Public Sub New ()

Dim B as Boolean = True

If B = True Then

' Processing

Else

' Processing

End If



End Sub

End Class




Select case
The Select Case statement is used for branching judgment execution of multiple results of a condition. It is worth noting that the Seleect case's judgment expression must be evaluated as a basic data type (Boolean, Byte, Char, Date, Double, Decimal, Integer, Long, Object, short, single, and String).

Vb. NET's case block cannot be "run through" to the next switch section. This is called the "no penetration" rule. So there's no need to break out of the case block.

The case clause can be a single variable, or it can be a mixed expression of to and is.



Select Csae Example

Public Class Testa

Public Sub New ()

Dim i as Int32 = 100



Select case I

Case 1, 3, 5, 7

' Processing

Case 8 to 12

' Processing

Case 21, 25

' Processing

Case A to > 50

' Processing

End Select

End Sub

End Class





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.