Debugging in VB6

Dear Expert,

I have written a DLL with about 10 functions and I have created a test harness (another project with a form) to those functions in the DLL.

I basically have 2 VB6 sessions open, one for the DLL and another for the test harness.

How do I get VB6 into debug mode for the DLL when I'm using the test harness and want to step into the DLL? I can step into the code for the test harness with ease, but I cannot seem to do the same for the DLL.

Who is Participating?
Try this:  

1. Open your test harness app in VB6.

2. With the test harness app open, click on File -> Add Project

3. Now open the DLL project file.

4. This will add the DLL project to your test harness app.
In other words, you just created a project Group.

5. Now with the DLL .vbp added to the group, you can set a reference to that DLL project
Make sure your harness app is the active application in the group and click
Project -> References menu.
Select your DLL from the list. (Note the the .VBP file will be displayed in the path)

6. Save this project group.
Create your object reference in code like you normally would:
   Dim objX As New myDLLObject

7. Put break points in your project where you access the DLL functions and you'll step right into them.

So if I have a DLL called MyDLL and this dll contains a function called SayHi, then I would have code something like this...
   Dim strText as string
   Dim objX As MyDLL
   Set objX = New MyDLL
   'Put your code break on the next line so you can step into the DLL function
   strText = objX.SayHi

   'Clean up after yourself.
   Set objX = Nothing

Hope this helps.
On the VB6 with the dll press F8,
Then the exe vb6 run the program,,
This should work.
FrohikeAuthor Commented:
It does not work when I try it. In fact, I had been doing this already.

The test harness is not an exe, I'm executing it by runnig (F5). When an error occurs whilst calling the DLL function, I can only step into the code that called the DLL function on the test harness, not the DLL function where I believe the error had originally come from.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

First you need to compile your test harness.
Then you open your dll project with VB and in Project Properties window, in debug options, define the program to run as your test harness.
Good luck.
FrohikeAuthor Commented:
I just want to clarify something, do you mean go to the Debugging tab and then select teh radio button for Start Program, and then browse for the test harness executable?
Just as you wrote!
By the way, sorry the tab name is debugging, not debug :-(.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.