Tuesday, May 12, 2009

select Control Structure Select Case....End

In the previous lesson, we have learned how to control the program flow using the If...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 basically only make decision on one expression or dimension (for example the examination grade) while the If ...ElseIf statement control structure may evaluate only one expression, each If....ElseIf statement may also compute entirely different dimensions. Select Case is preferred when there exist many different conditions because using If...Then..ElseIf statements might become too messy.
The format of the Select Case control structure is show below:

Select Case expression
Case value1 Block of one or more VB statements
Case value2 Block of one or more VB Statements
Case value3 . .
Case Else Block of one or more VB Statements
End Select

No comments:

Post a Comment