Visual Basic Concepts

Design Time, Run Time, and Break Mode

To test and debug an application, you need to understand which of three modes you are in at any given time. You use Visual Basic at design time to create an application, and at run time to run it. This chapter introduces break mode, which suspends the execution of the program so you can examine and alter data.

Identifying the Current Mode

The Visual Basic title bar always shows you the current mode. Figure 13.6 shows the title bar for design time, run time, and break mode.

Figure 13.6 Identifying the current mode with the Visual Basic title bar

The characteristics of the three modes are listed in the following table.

Mode Description
Design time Most of the work of creating an application is done at design time. You can design forms, draw controls, write code, and use the Properties window to set or view property settings. You cannot use the debugging tools, except for setting breakpoints and creating watch expressions.

From the Run menu, choose Start, or click the Run button to switch to run time.

If your application contains code that executes when the application starts, choose Step Into from the Run menu (or press F8) to place the application in break mode at the first executable statement.

Run time When an application takes control, you interact with the application the same way a user would. You can view code, but you cannot change it.

From the Run menu, choose End, or click the End button to switch back to design time.

Break mode From the Run menu, choose Break, click the Break button, or press CTRL+BREAK to switch to break mode.

Execution is suspended while running the application. You can view and edit code (choose Code from the View menu, or press F7), examine or modify data, restart the application, end execution, or continue execution from the same point.

You can set breakpoints and watch expressions at design time, but other debugging tools work only in break mode. See "Using Break Mode" later in this chapter.

Using the Toolbar to Change Modes

The toolbar provides three buttons that let you change quickly from one mode to another. These buttons appear in Figure 13.7.

Figure 13.7 Start, Break, and End buttons on the toolbar

Whether any of these buttons is available depends on whether Visual Basic is in run-time mode, design-time mode, or break mode. The following table lists the buttons available for different modes.

Mode Toolbar buttons available
Design time Start
Run time Break, End
Break Continue, End (in break mode, the Start button becomes the Continue button)