6.8. Using the Exit Statement in Repetition Statements

The Exit statement can be used to alter a program’s flow of control. There are many forms of the Exit statement, designed to exit different types of code blocks. In this section, we focus on using the Exit statement in repetition statements. The Exit Do statement can be executed in a Do While...Loop, Do...Loop While, Do Until...Loop or Do...Loop Until statement, to cause the program to exit immediately from that repetition statement. Similarly, the Exit For statement and the Exit While statement cause immediate exit from For...Next and While...End While loops, respectively. Execution continues with the first statement after the repetition statement. Figure 6.15 demonstrates the Exit For

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.