0
CONDITIONAL STATEMENTS
IF Statement <ul><li>Allows your program to make decisions based on certain conditions.  </li></ul>
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 ...
2. If… Then… Else <ul><li>Syntax:  </li></ul><ul><li>If  condition  Then </li></ul><ul><li>Statement/s </li></ul><ul><li>E...
IF… ELSEIF Statement <ul><li>If  1 st  condition   Then </li></ul><ul><li>statement if the 1st condition is true </li></ul...
Select Case Structure <ul><li>useful when you want to check a variable or an expression against multiple possible values  ...
Syntax for  “ Select Case ” <ul><li>Select Case  expression or variable </li></ul><ul><li>Case  range, constant, or variab...
<ul><li>Select Case lboColor.Text </li></ul><ul><li>Case “red”, “purple”, “orange” </li></ul><ul><li>lblRemark.Text = “Thi...
<ul><li>Select Case Val(T xtAge .Text) </li></ul><ul><li>Case 1 To 3 </li></ul><ul><li>lblRemark .Text = &quot;toddlerhood...
Upcoming SlideShare
Loading in...5
×

Select Case

416

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
416
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "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>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×