Solved

Invoke VB6 debugger programatticly

Posted on 2011-09-23
10
301 Views
Last Modified: 2012-05-12
I need to pause a vb6 app in the ide run mode on a certain condition so I can get to the debugger.

E.G.

>>
If MyCondition then
   Pause and go into debug mode
endif

Used to be 2nd nature but been a while :)
0
Comment
Question by:tfcallahan
  • 6
  • 2
  • 2
10 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 36590522
That's not possible.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 36590531
Sorry, I misread your question. To be able to use the debugger you need to put a breakpoint on a line of code that gets executed. Click in the left margin of a line to set a breakpoint.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 350 total points
ID: 36590540
Use the Stop instruction

If MyCondition then
   Stop
endif
0
 
LVL 45

Assisted Solution

by:Martin Liss
Martin Liss earned 150 total points
ID: 36590555
Both the Stop statement and a breakpoint do exactly the same thing, but be cautious with the Stop. If it's accidentally left in an exe it will be translated as an End and when ejected the program will end.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 36590571
You can also use the Assert statement which is ignored when compiled. Here's what MSDN has to say about Assert.


A Debug.Assert statement will never appear in a compiled application, but when you're running in the design environment it causes the application to enter break mode with the line containing the statement highlighted (assuming that the expression evaluates to False). The following example shows the Debug.Assert statement:

Debug.Assert Trim(CustName) = "John Doe"

In this case, if the CustName isn't John Doe, the application will enter break mode; otherwise the execution will continue as usual. Using Debug.Assert is similar to setting a watch with the Break When Value Is True option selected, except that it will break when the value is false.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Closing Comment

by:tfcallahan
ID: 36590574
Split points. Hope that's cool. Thanks!

I knew it was simple, just getting old I think :)
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 36590578
That's cool and BTW I'm 70 lol.
0
 

Author Comment

by:tfcallahan
ID: 36590579
p.s. re debug.assert, even better. Wish I could give more points but saw it late... :(
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 36590583
I'm happy with half.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 36591508
I'm older than you MartinLiss, so I deserve more points :>)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

11 Experts available now in Live!

Get 1:1 Help Now