[Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1869
  • Last Modified:

Debugging a VB6 OCX in a VB6 project

I'm trying to debug a VB6 OCX (activeX) in a VB6 project and I can't get it working. I have the OCX and the project file. I create a new project with a blank form and add the OCX component and I can't step into it. If I open up the project and add a form and then try to debug it, it doesn't run.

Whats the correct way to debug this?
1 Solution
Shahid ThaikaCommented:
Do you have the source code of the ocx and the project opened along with your executable project? If yes add the following statement... 'debug.assert false' one line before the code where you want to debug. The VB compiler should break at this point.
You need to have both projects loaded at the same time:

Start VB.
Open the project for your Active X Control.
The in File Select Add Project.
Start a new standard project.
Right click on the new project and select Set as Startup
make sure that the form for the Active X Control project closed (project still loaded - just close the form).
Open the form from the new project and add the Active X control (you may need to compile the control first)
Set your breakpoints
Now when you run - it will allow you to enter the code of the control.

Sparky191Author Commented:
I was already trying it with both projects open and the ocx on the new form, but it wouldn't step into the code. Someone elsewhere suggested I should add the vbp rather than the ocx as a component. This intially apeared as an option and then disappeared and now has reappeared so I  did that and its now working. But I didn't know about the  "Set as Startup" so I'll try that with a new project and see if it works.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now