<Previous Lesson> <<Home>> < Next Lesson>
In the previous lesson, we have learned how to control the program flow using the If...Then...ElseIf control structure. In this chapter, you will learn another way to control the program flow, that is, the Select Case control structure. However, the Select Case control structure is slightly different from the If....ElseIf control structure .
The difference is that the Select Case control structure can handle conditions with multiple outcomes in an easier manner than the If...Then...ElseIf control structure. If...Then...ElseIf control structure basically used to handle a single condition having more than two outcomes. Though If...Then...ElseIf control structure may also be used compute conditions with multiple outcomes, we need to use more than two levels of nested If...Then...ElseIf statements, this can make it difficult to read the codes. Therefore, the Select Case control structure is preferred when there exist many different conditions.
|
The format of the Select Case control structure is show below:
|
|
Example 8.2
|
|
Example 8.3
Example 8.2 can be rewritten as follows:
|
<Previous Lesson> <<Home>> < Next Lesson>
Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved |Contact: admin@vbtutor.net