際際滷

際際滷Share a Scribd company logo
SELECT CASE
 THE FANCY IF
The Problem With IF . . .

IF it is cold out THEN you will put a coat on
ELSE leave the coat at home

          But what about if it rains!
          We dont know what to do!

          Were going to have to
          make another IF statement
The Problem With IF . . .
IF it is cold out THEN you will put a coat on
ELSE leave the coat at home
IF its raining THEN you will put a coat on
ELSE leave the coat at home
           But what if its sunny! Were
           going to have make another
           IF statement
The Problem With IF . . .
IF it is cold out THEN you will put a coat on
ELSE leave the coat at home
IF its raining THEN you will put a coat on
ELSE leave the coat at home
IF its sunny THEN go and get you sunglasses
ELSE leave the sunglasses at home
          BUT WHAT IF ITS SNOWING!
The Problem With IF . . .
IF it is cold out THEN you will put a coat on
ELSE leave the coat at home
IF its raining THEN you will put a coat on
ELSE leave the coat at home
IF its sunny THEN go and get you sunglasses
ELSE leave the sunglasses at home
IF its snowing THEN go put on your snow joggers
ELSE leave the snow joggers at home
     This isnt very efficient! Plus its confusing
Select Case To The Rescue!
 Select case is like IF but allows you to test
  many things at once in one construct

 This is
   less confusing
   Easier to type up
   Easier to modify
Select Case To The Rescue!
 In Select case, a variable is tested using a criteria.


Case: Cold or                           Case: Sunny?
raining?                                Get your
Get your coat                           sunglasses
on!
                                        Case: Snow?
                                        Get your snow
                     Weather
                                        joggers on
Select Case in VB
Select Case WEATHER
    Case cold, raining
        put your coat on!
    Case sunny
        put your sunglasses on
    Case snow
        put your snow joggers on

End Select

More Related Content

Select case

  • 1. SELECT CASE THE FANCY IF
  • 2. The Problem With IF . . . IF it is cold out THEN you will put a coat on ELSE leave the coat at home But what about if it rains! We dont know what to do! Were going to have to make another IF statement
  • 3. The Problem With IF . . . IF it is cold out THEN you will put a coat on ELSE leave the coat at home IF its raining THEN you will put a coat on ELSE leave the coat at home But what if its sunny! Were going to have make another IF statement
  • 4. The Problem With IF . . . IF it is cold out THEN you will put a coat on ELSE leave the coat at home IF its raining THEN you will put a coat on ELSE leave the coat at home IF its sunny THEN go and get you sunglasses ELSE leave the sunglasses at home BUT WHAT IF ITS SNOWING!
  • 5. The Problem With IF . . . IF it is cold out THEN you will put a coat on ELSE leave the coat at home IF its raining THEN you will put a coat on ELSE leave the coat at home IF its sunny THEN go and get you sunglasses ELSE leave the sunglasses at home IF its snowing THEN go put on your snow joggers ELSE leave the snow joggers at home This isnt very efficient! Plus its confusing
  • 6. Select Case To The Rescue! Select case is like IF but allows you to test many things at once in one construct This is less confusing Easier to type up Easier to modify
  • 7. Select Case To The Rescue! In Select case, a variable is tested using a criteria. Case: Cold or Case: Sunny? raining? Get your Get your coat sunglasses on! Case: Snow? Get your snow Weather joggers on
  • 8. Select Case in VB Select Case WEATHER Case cold, raining put your coat on! Case sunny put your sunglasses on Case snow put your snow joggers on End Select