How can I add code to a timer object.
-
Hi, This is an easy one, I think. I have written a procedure behind a button e.g. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click I want to call this procedure from a timer function, how is this done? Thanks in advance.
-
Hi, This is an easy one, I think. I have written a procedure behind a button e.g. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click I want to call this procedure from a timer function, how is this done? Thanks in advance.
-
Hi, This is an easy one, I think. I have written a procedure behind a button e.g. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click I want to call this procedure from a timer function, how is this done? Thanks in advance.
1. why would you put code in a button click handler, if what you want is have it executed by a timer tick handler? 2. you can simulate a button being clicked by calling Button.PerformClick :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Please use <PRE> tags for code snippets, they improve readability.
CP Vanity has been updated to V2.3 -
Hi, This is an easy one, I think. I have written a procedure behind a button e.g. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click I want to call this procedure from a timer function, how is this done? Thanks in advance.
You don't put the code in the Button Click event handler. You put code in its own Sub, then call it from the Button Click handler and the Timer Tick event handler.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi, This is an easy one, I think. I have written a procedure behind a button e.g. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click I want to call this procedure from a timer function, how is this done? Thanks in advance.
just call btnProcess.PerformClick() in timer.tick event. or btnProcess_Click(sender, nothing) in timer.tick event.
-
just call btnProcess.PerformClick() in timer.tick event. or btnProcess_Click(sender, nothing) in timer.tick event.
That's the very wrong way to do it. It's lazy and leads to other possible issues that can't be traced down easily. If there is code that needs to be executed from multiple places you stick it in its own method with a name that has meaning as to what the code does. You don't "hide" it inside an event handler.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
That's the very wrong way to do it. It's lazy and leads to other possible issues that can't be traced down easily. If there is code that needs to be executed from multiple places you stick it in its own method with a name that has meaning as to what the code does. You don't "hide" it inside an event handler.
A guide to posting questions on CodeProject[^]
Dave Kreskowiakits up to the developer to decide... and ofcourse the one who asked this question knows how to move all the statements in the button's click event to a sub-routine and call the same sub-routine in the button's click event. its that simple..let them do in their own way. can you describe why it is wrong way?
-
its up to the developer to decide... and ofcourse the one who asked this question knows how to move all the statements in the button's click event to a sub-routine and call the same sub-routine in the button's click event. its that simple..let them do in their own way. can you describe why it is wrong way?
I already did.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak