Upcoming SlideShare
×

# Select Case

628 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
628
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
6
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Select Case

1. 1. CONDITIONAL STATEMENTS
2. 2. IF Statement <ul><li>Allows your program to make decisions based on certain conditions. </li></ul>
3. 3. 1. If… Then <ul><li>Syntax: </li></ul><ul><li>If condition Then </li></ul><ul><li>Statement/s </li></ul><ul><li>End If </li></ul>
4. 4. 2. If… Then… Else <ul><li>Syntax: </li></ul><ul><li>If condition Then </li></ul><ul><li>Statement/s </li></ul><ul><li>Else </li></ul><ul><li>Statement/s </li></ul><ul><li>End If </li></ul>
5. 5. IF… ELSEIF Statement <ul><li>If 1 st condition Then </li></ul><ul><li>statement if the 1st condition is true </li></ul><ul><li>ElseIf 2 nd condition Then </li></ul><ul><li>statement if the 2nd condition is true </li></ul><ul><li>Else </li></ul><ul><li> statement if ALL conditions are false </li></ul><ul><li>End If </li></ul>
6. 6. Select Case Structure <ul><li>useful when you want to check a variable or an expression against multiple possible values </li></ul>
7. 7. Syntax for “ Select Case ” <ul><li>Select Case expression or variable </li></ul><ul><li>Case range, constant, or variable </li></ul><ul><li>‘ Statements </li></ul><ul><li>Case range, constant, or variable </li></ul><ul><li>‘ Statements </li></ul><ul><li>Case range, constant, or variable </li></ul><ul><li>‘ Statements </li></ul><ul><li>Case Else </li></ul><ul><li>‘ Statements </li></ul><ul><li>End Select </li></ul>
8. 8. <ul><li>Select Case lboColor.Text </li></ul><ul><li>Case “red”, “purple”, “orange” </li></ul><ul><li>lblRemark.Text = “This is a warm color.” </li></ul><ul><li>Case “blue”, “green”, “blue violet” </li></ul><ul><li>lblRemark.Text = “This is a cool color.” </li></ul><ul><li>Case Else </li></ul><ul><li>lblRemark.Text = “Please select a color.” </li></ul><ul><li>End Case </li></ul>
9. 9. <ul><li>Select Case Val(T xtAge .Text) </li></ul><ul><li>Case 1 To 3 </li></ul><ul><li>lblRemark .Text = &quot;toddlerhood&quot; </li></ul><ul><li>Case 4 To 8 </li></ul><ul><li>lblRemark .Text = &quot;childhood&quot; </li></ul><ul><li>Case 9 To 12 </li></ul><ul><li>lblRemark .Text = &quot;preadolescence&quot; </li></ul><ul><li>Case 13 To 18 </li></ul><ul><li>lblRemark .Text = &quot;adolescence&quot; </li></ul><ul><li>Case 19 To 24 </li></ul><ul><li>lblRemark .Text = &quot;young adulthood&quot; </li></ul><ul><li>Case Is > 24 </li></ul><ul><li>lblRemark .Text = &quot;adulthood&quot; </li></ul><ul><li>Case Else </li></ul><ul><li>lblRemark .Text = &quot;infancy&quot; </li></ul><ul><li>End Select </li></ul>