Debugging in VB6

Posted on 2005-04-19
Last Modified: 2010-04-17
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.

Question by:Frohike
    LVL 2

    Expert Comment

    On the VB6 with the dll press F8,
    Then the exe vb6 run the program,,
    This should work.

    Author Comment

    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.

    Expert Comment

    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.

    Author Comment

    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?
    LVL 3

    Accepted Solution

    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.

    Expert Comment

    Just as you wrote!
    By the way, sorry the tab name is debugging, not debug :-(.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    scores100 challenge 3 67
    array11 challenge 16 40
    countAbc challenge 9 35
    Path of Workbook 3 30
    A short article about problems I had with the new location API and permissions in Marshmallow
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now