Link to home
Start Free TrialLog in
Avatar of perkinda
perkinda

asked on

Getting a Stack Trace in VB6 code

I have a vb6 that uses a function called from many places and many times.  At some point, I am getting an error and need to have a stack trace to find out where the problem originates.  Is there a way to get a stack trace at a particular point in a vb6 program?  The program has a logger built into it that I could use.
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

You can't do it without additional code. Here is one example:

http://www.vbaccelerator.com/home/vb/code/Techniques/RunTime_Debug_Tracing/article.asp

Kevin
Avatar of perkinda
perkinda

ASKER

I really need the stack trace at a particular point in the program.  I have tried to get BlackBox to work,  http://www.codeproject.com/tools/blackbox.asp ) but have had no success.  This is supposed to work with VB6.

Have you had any luck using this tool with vb6?
No. I have not used any third party tools.

The VB debugging tools suck in compiled form. Running in the debugger is fine but when your customer crashes the program you have nothing. There are three basic techniques I use. The first and most basic/crude is to wait until bad stuff happens and then put MsgBox statements in what you suspect are the problem areas as you work with the customer. This requires a great deal of analytical skill and luck so as to minimize the customer interaction. But sometimes it's the quickest way to a solution.

Another technique is logging to a file. If designed up front this can work very well. All a customer has to do is send you the log file which, if you put in a decent amount of logging in the right places, will do a lot to help find the problem. I'm trying to do this more and more these days.

A third technique is to insert your own tracing code inside the application. There was a point where I actually preferred this technique and even had some code to edit my source and put in all the trace calls (procedure start and end calls). But that was a long time ago and the code is long gone.

Kevin
ASKER CERTIFIED SOLUTION
Avatar of Anthony2000
Anthony2000
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Zorvek.  I have already tried all your suggestions, but what I really need is the stack trace when the error occurs.  I know exactly what the error is, but I don't know what is throwing it.

Anthony2000 - I'll try the dll.  This one may work as it is in VB5.  I have tried a c++ dll that was supposed to do the same thing, but I could not get it to work.  I'll let you know!
What I usually do in each of my subs and functions is to add "on error goto error_handler". In the error_handler I log the error as zorvek had suggested. Then I usually can find the problem by looking at the log file. I log the sub/function name along with the err.description.
Thanks all for your help.  l could not get the C++  BlackBox dll to work, but the VB5 Babbacomb dll works great - so I gave the points to Anthony