How to Use vb.net switch statements

Source: Internet
Author: User
Tags switch case

CopyPublic Function Switch (_
ByVal ParamArray VarExpr () As Object _
) As Object

Instance

Function matchLanguage (ByVal cityName As String) As String
Return CStr (Microsoft. VisualBasic. Switch (_
CityName = "London", "English ",_
CityName = "Rome", "Italian ",_
CityName = "Paris", "French "))
End Function


Let's look at a simple example.

Module Module1

Sub Main ()
Dim intValue As Integer =-10


Console. WriteLine ("Absolute value :"&_
Microsoft. VisualBasic. Switch (intValue <0,-1 * intValue, intValue> = 0, intValue ))
End Sub

End Module

If the condensation switch case syntax is as follows:

Case requires a range of values or values. The expression after your current Case is True or False.
Either use If all or modify as follows


VB. NET code
Select case myrow1.Cells ("points"). Value
Case 0
...
Case 60 to 79
...
Case 80 to 99
...
Case is> 100
...
Case else
...
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.