Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 35,051 times

Contents

Related Categories

Debugging - The Call Stack Window

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.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments