O'Reilly logo

Absolute Beginner's Guide to Programming, Second Edition by Greg Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting with Select Case

The Select Case statement is better suited to checking for multiple conditions than is If, even when utilizing the logical operators. The use of more than three or four embedded If...Else statements results in a complicated program. You get into messy logic such as "If this is true, then if this is true, then if one more thing is true, then do something, otherwise…" Here is the Select Case statement's format:

Select Case Expression
  Case expressionMatch
						     Block of one or more Visual Basic statements
  [ Case expressionMatch1
						Block of one or more Visual Basic statements]
  [ Case expressionMatch2
						Block of one or more Visual Basic statements]
      :
  [ Case expressionMatchN
						Block of one or more Visual Basic statements] [Case Else ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required