Prev: Redirection
Next: Correct Way To Wait
From: Webbiz on 3 Mar 2010 15:14 Over the last months/years, I've been shown some simple approaches to debugging here for which I'm grateful. But for the life of me, I can't recall some of them and my scraps of paper they were written on is buried deep amonst my many piled books and papers. So I'm putting a notebook together once and for all so I don't have to repeat my desperate calls for help on a topic already addressed. Perhaps some of you can remind me of a few basic items. ==================== Q. How does one get a list of the procedures in the order they are being called within a VB6 project? (I wish to do this to find those procedures that are being called more times than necessary, as well as the 'order' in which these are being called. Time to clean up some old code.) Q. What is the proper way to 'break' the code at a particular location when a variable contains a certain value? For example, when a loop finally comes to a certain DATE and you want to stop the code right there to view the variable values in order to fix a bug? (I find myself using my old habit of years, that of doing this: If MyArray(x).dDate = "01/12/2010" then x = x End if And then placing a BREAK on x=x. I recall someone showing me the proper way to do this, but it didn't become a habit and now I forgot what that was. ) Thanks. Webbiz
From: Ivar on 3 Mar 2010 15:55 > Q. How does one get a list of the procedures in the order they are > being called within a VB6 project? You mean the Call Stack. View\CallStack or CTRL+L > Q. What is the proper way to 'break' the code at a particular location > when a variable contains a certain value? For example, when a loop > finally comes to a certain DATE and you want to stop the code right > there to view the variable values in order to fix a bug? You mean the Watch Window. View\Watch Window. or Alt+V+H Look for Call Stack and Watch Window in MSDN Ivar
From: Nobody on 3 Mar 2010 15:56 "Webbiz" <nospam(a)noway.com> wrote in message news:acgto5p513j1g6j0n2e0dpmvpvs79t96gr(a)4ax.com... > Q. How does one get a list of the procedures in the order they are > being called within a VB6 project? > > (I wish to do this to find those procedures that are being called more > times than necessary, as well as the 'order' in which these are being > called. Time to clean up some old code.) Perhaps by View-->Call Stack, or by using MZTools Addin, or other Addins. MZTools Addin can show you procedure callers, and can search by excluding comments. > Q. What is the proper way to 'break' the code at a particular location > when a variable contains a certain value? For example, when a loop > finally comes to a certain DATE and you want to stop the code right > there to view the variable values in order to fix a bug? View-->Watch Window, then right click and use Add Watch. You can also highlight part of the code and right click and use Add Watch. Another option, but works in specific places is by using Debug.Assert.
From: MikeD on 3 Mar 2010 19:32 "Webbiz" <nospam(a)noway.com> wrote in message news:acgto5p513j1g6j0n2e0dpmvpvs79t96gr(a)4ax.com... > > Q. How does one get a list of the procedures in the order they are > being called within a VB6 project? > This would be the call stack. You can choose it from the View menu, but I think it's easier to use its keyboard short, which is Ctrl+L. Of course, you can only do this when running your project in the IDE and only when already in break mode. If you're talking about other circumstances, you can't. Remember, VB is event-driven. Event procedures are only called when a user performs a matching even for the object and other procedures are only called from event procedures. So, the order in which many procedures are called is a variable based on the user's actions. > (I wish to do this to find those procedures that are being called more > times than necessary, as well as the 'order' in which these are being > called. Time to clean up some old code.) That's sometimes very difficult to do. Sometimes you simply can't do anything about it.; other than make sure it's not detrimental. > > > Q. What is the proper way to 'break' the code at a particular location > when a variable contains a certain value? For example, when a loop > finally comes to a certain DATE and you want to stop the code right > there to view the variable values in order to fix a bug? > Numerous ways to do this. You could set a Watch for that variable and specify criteria for when a break should occur (like when that variable has a specific value or simply whenever its assigned value changes). You could also write Debug.Assert statements into your code. These do not normally get compiled so there's no bloat including them in your source code. There is a caveat though and that involves calling a user-defined procedure (a function, sub, or even property Let/Get/Set procedure) as part of the expression used in the assertion. Best to keep the expression of any Debug.Assert statements as simple as possible. -- Mike
From: Henning on 3 Mar 2010 19:46
"MikeD" <nobody(a)nowhere.edu> skrev i meddelandet news:%23I4tnIzuKHA.2436(a)TK2MSFTNGP04.phx.gbl... > > > "Webbiz" <nospam(a)noway.com> wrote in message > news:acgto5p513j1g6j0n2e0dpmvpvs79t96gr(a)4ax.com... > >> >> Q. How does one get a list of the procedures in the order they are >> being called within a VB6 project? >> > > This would be the call stack. You can choose it from the View menu, but I > think it's easier to use its keyboard short, which is Ctrl+L. Of course, > you can only do this when running your project in the IDE and only when > already in break mode. If you're talking about other circumstances, you > can't. Remember, VB is event-driven. Event procedures are only called when > a user performs a matching even for the object and other procedures are > only called from event procedures. So, the order in which many procedures > are called is a variable based on the user's actions. > >> (I wish to do this to find those procedures that are being called more >> times than necessary, as well as the 'order' in which these are being >> called. Time to clean up some old code.) > > That's sometimes very difficult to do. Sometimes you simply can't do > anything about it.; other than make sure it's not detrimental. > >> >> >> Q. What is the proper way to 'break' the code at a particular location >> when a variable contains a certain value? For example, when a loop >> finally comes to a certain DATE and you want to stop the code right >> there to view the variable values in order to fix a bug? >> > > Numerous ways to do this. You could set a Watch for that variable and > specify criteria for when a break should occur (like when that variable > has a specific value or simply whenever its assigned value changes). > > You could also write Debug.Assert statements into your code. These do not > normally get compiled so there's no bloat including them in your source > code. There is a caveat though and that involves calling a user-defined > procedure (a function, sub, or even property Let/Get/Set procedure) as > part of the expression used in the assertion. Best to keep the expression > of any Debug.Assert statements as simple as possible. > > > -- > Mike > > Just curious, how can a Sub/Function be called more times than necessary?? I always think the other way around, if the same code is needed in more than one place, make it a Sub/Function. /Henning |