- Version
- Download 39
- File Size 63.18 KB
- File Count 1
- Create Date May 7, 2016
- Last Updated May 7, 2016
Select Case Statement in Visual Basic .Net
Select Case Statement in Visual Basic .Net
Select Case statement is a conditional statement just like the if else statement.
This is an example of vb.net program that shows how to use the select case statement.
Select case statement only evaluates one variable then matches it or compare it to the case labels.
Open the project solution (.sln) in visual studio 2010 or open directly the project file (.csproj)
Source code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mycolor As String = ComboBox1.Text
Select Case mycolor
Case "Red"
MessageBox.Show("Red is the color of fire and blood")
Case "Orange"
MessageBox.Show("Orange represents enthusiasm, fascination, happiness, creativity, determination, attraction, success, encouragement, and stimulation.")
Case "Yellow"
MessageBox.Show("Yellow is the color of sunshine")
Case "Green"
MessageBox.Show("Green is the color of nature")
Case "Blue"
MessageBox.Show("Blue is the color of the sky and sea")
Case "Indigo"
MessageBox.Show("Indigo is the color of intuition")
Case "Violet"
MessageBox.Show("purple or violet as your favorite color means you are sensitive and compassionate")
Case Else
MessageBox.Show("not found")
End Select
End Sub
End Class