来自:Julitta Korol,“Access.2003.Programming.by.Example.with.VBA.XML.and.ASP”,by Wordware Publishing, Inc. 2005, p91-p101
(1)Using the Do…While Loop
(2)continuously display an input box until the user enters the correct password
(3)Another Approach to the Do…While Loop
When you test the condition at the bottom of the loop, the statements inside the loop are executed at least once.
(4)Infinite Loops:
To stop the execution of the infinite loop, you must press Ctrl+Break. When Visual Basic displays the message box “Code execution has been interrupted,”click End to end the procedure.
(5)Do…Until repeats a block of code as long as something is false.
(6)
If you want the statements to execute at least once, no matter what the value of the condition, place the condition on the line with the Loop statement.
(7)
(8)
Element is a variable to which all the elements of an array or collection will be assigned. This variable has to be of the Variant data type for an array and of the Object data type for a collection. Group is a name of a collection or an array.
(9)Exiting Loops Early: Exit For, Exit Do, Exit Sub, Exit Function.
(10)When writing nested loops, you must make sure that each inner loop is completely contained inside the outer loop. Also, each loop has to have a unique counter variable.