Setting a Breakpoint in Your Code

Setting a Breakpoint in Your Code

You'll often encounter errors that are not obvious, and you'll need to step through sections of code line by line. To help you step through code, you can add a breakpoint. To set a breakpoint, you first find the line of code you want to start stepping through and then click in the left border of the IDE. A red dot indicates that a breakpoint has been set. If you want to remove the breakpoint, click the dot, and it's removed. Figure 7-8 shows how a breakpoint is represented.

Figure 7-8

Program execution will temporarily halt when it reaches this breakpoint.

You can set breakpoints only on lines of code that are executed. For example, if you tried to set a breakpoint on the declaration of our two integers—Dim iInput, iCounter As Integer—the compiler would alert you that setting a breakpoint here is not a good idea. In the first panel of the status bar in the lower left of the IDE window, you would get a message from the compiler, as shown in Figure 7-9.

Figure 7-9

The compiler warns you if you try to set a breakpoint on a nonexecutable line of code.



Coding Techniques for Microsoft Visual Basic. NET
Coding Techniques for Microsoft Visual Basic .NET
ISBN: 0735612544
EAN: 2147483647
Year: 2002
Pages: 123
Authors: John Connell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net