Prev: Redirection
Next: Correct Way To Wait
From: Webbiz on 4 Mar 2010 03:06 >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 > I had a break set in my DrawChart routine the other day and ran the program. This routine draws a chart on a picturebox. When I continued the program from that single break point, it returned to that break point again. I realized, at that point, that I need to make sure my procedures are not being called unnecessarily. Why do I need to draw the same chart twice? The DrawChart is called from MANY locations within the program. It is called when the user scrolls. It is called when the user changes the time frame. It is called when the user draws on the chart. It is called when the user deletes something from the chart. Etc. Etc. However, calling it twice when first starting the app is unnecessary. So I will have to locate why and remedy it. Meanwhile, I'm thinking that it would be great if I could generate a list that shows the order in which the procedures are called from the point I start the program until the point it stops initializing (drawing the chart, etc.) and sits there waiting for someone to click something. It appears from the comments that this can't be done? I tried the Call Stack thingy but didn't see such a list. Probably not using it right or something. Dunno. Webbiz
From: Dee Earley on 4 Mar 2010 04:53 On 03/03/2010 20:14, Webbiz wrote: > Over the last months/years, I've been shown some simple approaches to > debugging here for which I'm grateful. Further to the other answers, this page explains some other general debugging concepts: http://hashvb.earlsoft.co.uk/Debugging -- Dee Earley (dee.earley(a)icode.co.uk) i-Catcher Development Team iCode Systems
From: Nobody on 4 Mar 2010 05:45 "Webbiz" <nospam(a)noway.com> wrote in message news:8spuo5p4clr3vlk62lk0vjah5a29mfp1cc(a)4ax.com... > >>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 >> > > > I had a break set in my DrawChart routine the other day and ran the > program. This routine draws a chart on a picturebox. > > When I continued the program from that single break point, it returned > to that break point again. > > I realized, at that point, that I need to make sure my procedures are > not being called unnecessarily. Why do I need to draw the same chart > twice? > > The DrawChart is called from MANY locations within the program. It is > called when the user scrolls. It is called when the user changes the > time frame. It is called when the user draws on the chart. It is > called when the user deletes something from the chart. Etc. Etc. Try adding a CallerID parameter at the end. Example: Public Sub DrawChart(..., Optional ByVal CallerID As Long) Debug.Print "DrawChart: called, CallerID = " & CallerID ... End Sub
From: David on 4 Mar 2010 07:19 I use this at the beginning and end of all my procedures #If kDEBUGON Then Debug.Print "----------------------------------------" Debug.Print "Begin ToolDragBegin" #End If kDEBUGON placed in: Project / Properties / Make / Conditional Compile Arguments If kDEBUGON = 0 then it is ignored. If kDEBUGON = 1 then it is executed. ============== Note this will generate a lot of debug statements "Nobody" <nobody(a)nobody.com> wrote in message news:uRNEdf4uKHA.5036(a)TK2MSFTNGP02.phx.gbl... > "Webbiz" <nospam(a)noway.com> wrote in message > news:8spuo5p4clr3vlk62lk0vjah5a29mfp1cc(a)4ax.com... >> >>>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 >>> >> >> >> I had a break set in my DrawChart routine the other day and ran the >> program. This routine draws a chart on a picturebox. >> >> When I continued the program from that single break point, it returned >> to that break point again. >> >> I realized, at that point, that I need to make sure my procedures are >> not being called unnecessarily. Why do I need to draw the same chart >> twice? >> >> The DrawChart is called from MANY locations within the program. It is >> called when the user scrolls. It is called when the user changes the >> time frame. It is called when the user draws on the chart. It is >> called when the user deletes something from the chart. Etc. Etc. > > Try adding a CallerID parameter at the end. Example: > > Public Sub DrawChart(..., Optional ByVal CallerID As Long) > Debug.Print "DrawChart: called, CallerID = " & CallerID > ... > End Sub > >
From: Larry Serflaten on 4 Mar 2010 07:51
"Webbiz" <nospam(a)noway.com> wrote > Meanwhile, I'm thinking that it would be great if I could generate a > list that shows the order in which the procedures are called from the > point I start the program until the point it stops initializing > (drawing the chart, etc.) and sits there waiting for someone to click > something. > > It appears from the comments that this can't be done? You should know better than that! Load your project, and press F8. Then get your pen and paper and write down the routines as they are called. Keep pressing F8 until pressing F8 does nothing. It is at that point that your program is waiting for user input. LFS |