Manzione Do While
Manzione Do While
Statements
Manzione
• Primary use:
– To automate a program to read a block of statements
that are either ‘true until false’ or ‘false until true’
1
“Do While… Loop”
• A "Do While" loop statement runs while a
logical expression is true.
• This means that as long as your
expression stays true, your program will
keep on running.
• Once the expression is false, your
program stops running.
2
“Do Until… Loop”
• A "Do Until" loop statement runs until a
logical statement is true.
• This means that as long as your
expression is false, the program will run
until it is true.
• Once the expression is true, the program
stops running.
3
“For… Next” Statements
• “For… Next” statements begin with a “For”
keyword and end with a “Next”
• 2 types of “For” Statements
– “For… Next” and “For Each… Next”
• Primary use:
– To automate a program to read a block of statements
until the statement runs a given number of times as
determined by the start, end, and step values.
4
Example of “For… Next”
For variable = StartValue To EndValue
‘ Block of code inserted here
Next
For x = 1 to 10
‘ Code to print file
MsgBox "Printing File " & x
Next
5
Example of “For Each… Next”
For Each element In group
‘ Insert statement here
Next
Text Pages
• Programming ArcObjects with VBA
– “Do… Loop” Statements: Pages 23-24
– “For… Next” Statements: Pages 24-25