|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Stopping an EventCan anyone remind me how to stop an event from firing? I mean once the event
fires the first line of code is "Stop events from firing" and then I can turn it back on at the end of that event??? "HotRod" <NOSPAM@youremail.com> wrote in message Normally, you can't stop the event from firing. I say "normally" because news:%238MNyu10FHA.2076@TK2MSFTNGP14.phx.gbl... > Can anyone remind me how to stop an event from firing? I mean once the > event fires the first line of code is "Stop events from firing" and then I > can turn it back on at the end of that event??? there are controls/components with a property (for example) that can be set to ignore certain events (for example, not raise them). However, this would have to be functionality specifically written into the component. Other than that possibility, the only thing you can do is have a module-level variable to which you assign a value and then check for that value in the event procedure itself, and if, appropriate, exit the event procedure. -- Mike Microsoft MVP Visual Basic On Mon, 17 Oct 2005 16:45:15 -0400, "HotRod" <NOSPAM@youremail.com> If you just want to prevent re-entry in the current proceedure you canwrote: >Can anyone remind me how to stop an event from firing? I mean once the event >fires the first line of code is "Stop events from firing" and then I can >turn it back on at the end of that event??? use a static var as a flag. Private Sub SomeSub() Static bBusy As Boolean If Not bBusy Then bBusy = True '...do whatever ... bBusy = False End If End Sub -Tom MVP - Visual Basic (please post replies to the newsgroup) "HotRod" <NOSPAM@youremail.com> wrote in message I'm not sure what you mean. Do you by any chance mean "how can I stop news:%238MNyu10FHA.2076@TK2MSFTNGP14.phx.gbl... > Can anyone remind me how to stop an event from firing? I mean once > the event fires the first line of code is "Stop events from firing" and > then > I can turn it back on at the end of that event??? further button click events from firing while my code processes the last click", ort is it something more general that that? Mike Mike your right, I want the Event to complete before trying to fire the
event again. "HotRod" <NOSPAM@youremail.com> wrote in message If it is a Command Button Click event then just place the line news:%236GOCD$0FHA.3780@TK2MSFTNGP12.phx.gbl... > Mike your right, I want the Event to complete before trying > to fire the event again. "Command1.Enabled = False" at the start of the event code and the lines "Doevents" followed by "Command1.Enabled = False" at the end of the event code (other objects can be dealt with in a similar way). If instead it is a general thing (and the event code is in a Form, for example) then maintain a Form level Boolean (Working, for example) and put something like the following at the start of the event code: If Working = True Then Exit Sub Else Working = True End If ' your event code here ' DoEvents Working = False End Sub If that doesn't help you then I've misunderstood your problem, so post again. Mike Here is how I do it with a Timer:
Dim bTimer1Busy As Boolean Private Sub Timer1_Timer() If bTimer1Busy Then Exit Sub End If bTimer1Busy = True ' Your code here bTimer1Busy = False End Sub Show quoteHide quote "HotRod" <NOSPAM@youremail.com> wrote in message news:%236GOCD$0FHA.3780@TK2MSFTNGP12.phx.gbl... > Mike your right, I want the Event to complete before trying to fire the > event again. > |
|||||||||||||||||||||||