Solved

Invoke VB6 debugger programatticly

Posted on 2011-09-23
10
303 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 46

Expert Comment

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

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 46

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 46

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
 

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 46

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 46

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

Gigs: Get Your Project Delivered by an Expert

Select from 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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 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