Stop Statement
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Stop Statement

Suspends execution.



You can place Stop statements anywhere in procedures to suspend execution. Using the Stop statement is similar to setting a breakpoint in the code.

The Stop statement suspends execution, but unlike End, it does not close any files or clear any variables, unless it is encountered in a compiled executable (.exe) file.

Note   If the Stop statement is encountered in code that is running outside of the integrated development environment (IDE), the debugger is invoked. This is true regardless of whether the code was compiled in debug or retail mode.


This example uses the Stop statement to suspend execution for each iteration through the For...Next loop.

Dim I As Integer
For I = 1 To 10   ' Start For...Next loop.
   Debug.WriteLine (I)   ' Print I to the Output window.
   Stop   ' Stop during each iteration and wait for user to resume.
Next I

See Also

End Statement

© 2016 Microsoft