Library tutorials & articles

Debugging

The Call Stack Window

Ever pressed Ctrl+Break (enter Break Mode), with code execution stopped in a procedure and wanted to know what procedure called it? Well, the Call Stack window shows you just that:


Call Stack Window

As an example, create a new project with a command button, and enter the following code:

Public gTest As Integer
Sub Command1_click()
    Call SubRoutine1
End Sub
Sub SubRoutine1()
    Call SubRoutine2
End Sub
Sub SubRoutine2()
    ' Do something
    gTest = 1
    Stop ' Code stops here
End Sub

Run the project and press Command1. Visual Basic will enter Break Mode when it reaches the Stop statement in SubRoutine2. Now show the Call Stack window by selecting Call Stack from the View menu. You will now see three procedures listed in the box. The first item in the listbox will be SubRoutine2. At the bottom is the original event (Command1_Click()). The listbox lists all the procedures that have been called to get to the current procedure bottom up (bottom is the first procedure). So, if the listbox contained these items:

Project1.Form1.SubRoutine2 ' This procedure was called.
Project1.Form1.SubRoutine1 ' This procedure was called, and in turn called the above procedure
Project1.Form1.Command1_Click ' This event occured, which called the above procedure

The information before the Procedure name (Project1.Form1) shows what project, and what module the procedure belongs to. To go to the selected procedure, click Show.

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Debugging.

Leave a comment

Sign in or Join us (it's free).

James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!