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