Question #55280

what statement allows many branches or alternative paths ?
1

Expert's answer

2016-01-20T13:16:52-0500

Answer on Question#55280, Programming | Visual Basic

what statement allows many branches or alternative paths?

Solution

Main construction allow many branches is switch... case technology. View of case statement:


Select [ Case ] testexpression
[ Case expressionlist
[ statements ] ]
[ Case Else
[ elsestatements ] ]
End Select

Where testexpression evaluate to one of the elementary data types

Required in a Case statement. List of expression clauses representing match values for testexpression. Multiple expression clauses are separated by commas. Each clause can take one of the following forms:

- expression1 To expression2

- [Is] comparisonoperator expression

- expression

Use the To keyword to specify the boundaries of a range of match values for testexpression. The value of expression1 must be less than or equal to the value of expression2.

As example: show messages with different information about a corresponding to value a


Sub Test()
a = 3
Select Case a
Case Is > 5
    MsgBox "greater than 5"
Case Is > 7
    MsgBox "greater than 7"
Case Else
    MsgBox "Didn't work any condition"
End Select
End Sub


http://www.AssignmentExpert.com/

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS