SyntaxDo [{While | Until} condition] [statements] [Exit Do] [statements] [Continue Do] [statements] Loop or: Do [statements] [Exit Do] [statements] [Continue Do] [statements] Loop [{While | Until} condition]
DescriptionThe Do...Loop statement repeatedly executes program code while (or until) a given condition remains TRue. When used with the While clause, the loop block is executed each time condition evaluates to true; when used with the Until clause, the loop block is executed until condition evaluates to true. Once the sustaining condition is no longer met, the entire loop is exited. The Exit Do statement can be used at any time to exit the Do loop early. If the condition appears at the top of the loop construct, the code within the loop might execute zero or more times, depending on the evaluation result of condition. When the condition appears at the bottom of the loop construct, the code within the loop always executes at least once. New in 2005. The Continue Do statement can be used at any time to immediately jump back to the top of the loop and attempt to process the next iteration. The condition is reevaluated immediately upon reaching the top of the loop (or the bottom, if the condition is located there). Usage at a Glance
Version DifferencesVisual Basic 2005 includes the Continue Do statement. See AlsoWhile...End While Statement |