Professional Documents
Culture Documents
Controlling Program Flow
Controlling Program Flow
PROGRAM
FLOW
ผศ.ดร. นาถฤดี ศุภกิจจาร ักษ ์
• Create Comparisons
• Make Use of Logical Operators
• Employ Do While Loops
• Create Do Until Loops
• Create For Next Loops
• Create If Then Else Statements
• Construct Select Case Statements
• GoTo a Named Location
• Call a Procedure
CREATE COMPARISON
• Execute VBA or a series of VBA • We can also use the
statements as long as a condition
is True by using Do While loop. following syntax to create a
Do-Loop
Do [While condition]
[Statement]
Do
Loop [Statement]
• A condition is an expression that Loop [While condition]
evaluates to either True or False. If
the condition is True, it executes
the statement. If the conditions is
False, VBA executes the statement
after the Loop statement
Do Until Loops
Exercise
1. New procedure
2. Declare variable
3. Add a For statement
1. Counter variable
2. Initial value
3. Maximum value
4. [Statement] to execute
5. Add a Next statement
Tax
TX 5%, FL 8%,CA 10%, else No tax
Exercise
1. New procedure
2. Declare variable
Select Case testexpression
3. Initialize variable [caseexpressionlist –n
4. Create a Do While loop [statements-n]
[Eesetatement]
6. Type Case statement
End Select
7. Add Case Else statement
8. Add End Select statement