When VB runs a
program, it executes the code at lightening speed. You use a breakpoint
to tell VB to stop your programme at a particular place, so you can
step through the code line by line.
It's easy to
add a breakpoint. You just add one by clicking in the margins. A brown
circled then appears, indicating where the code will break. The
following two images show how to add one:
Adding a breakpoint |
The code
below does not have a breakpoint

Now I will
add a breakpoint
When you click in the margins, to the left of a line of code, a brown
circle appears:
 |
Notice that the line where you want VB to break is highlighted brown.
You can put on as many breakpoints as you like but until you are used to
them. For now it's best just to stick with one breakpoint.
It is just as easy to remove
breakpoints, just click on the brown spot and it will go away.
~~~~ When you have added your breakpoint...
...all you have to do then is run your program
as normal~~~~
When you
run a program with a breakpoint, VB will halt at any line of code with a
breakpoint and show you the coding window.
The place where you put the breakpoint will now have a yellow arrow on
top of the brown circle. The brown highlighted line will now be yellow:
Running the
Program |
VB stops at
a breakpoint
 |
The yellow highlight indicates where in your code VB is. You can now
instruct VB to step line by line through your code by pressing F8 on
your keyboard. When you press F8, it will execute the currently
highlighted line and then move onto the next line which will be then be
highlighted.
Stepping Through
your Code |
Use F8 to
step to the next line

The yellow arrow, and the yellow highlight,
jump down one line. |
If you press
the F8 key again, it will jump to the next line. In fact, every time
you press F8, VB executes the highlighted line and then jumps to the
next line and stops again, waiting for you to press F8 again.
~~~~You should
note VB does not execute the highlighted line until...
...after you have
pressed F8 and it has moved on to the next line.~~~~
Now here is the
important part. The step-by-step execution of code can help you locate the
errors in your code. If you hover your mouse over a variable, the value
this variable currently holds will be displayed: See below. You can see
a little tooltip showing the value of the variable.
