Pause/Resume code with button on form

thechazm

VBA, VB.net, C#, Java
Local time
Today, 00:38
Joined
Mar 7, 2011
Messages
515
I have tried many meathods that would allow the user to pause/resume the currently executing code on the same form but with very little luck.

If anyone can shed some light on this please let me know. Thanks,

TheChazm
 
Thanks for the reply but alas the information on the link does not really suit the need. The problem is I would like to have a Pause/Resume button to halt the code after a certain point and then allow the user to resume after they come back. I do however understand the benifits of using the sleep function over pause. I just have no idea how to get the button to respond when the code is already running.

If maybe I have missed something please let me know.

Thanks again,

TheChazm
 
No, you haven't missed anything... you could lauch a button that calls a form in dialog mode (which pauses the code) and then once they close the form the code will resume. Make it so they press the button a from open that says Click to Resume closing the dialog form thereby restarting the code.
 
Thank you so much for your helpful Idea. It does sound like it would work. I will give it a shot and post back the results.

TheChazm
 
you don't even need to open a form - you could just use the button to set a boolean flag, and then loop forever while the boolean is true. you need some way of signalling the "hold" status to the user though, maybe. Maybe just change the button caption (or a label caption). This sort of thing


Code:
[B]sub buttonclickevent
holdflag = not holdflag 

if holdflag then
    button.caption = "program paused. Click to continue."
else
    button.caption = "program running normally. Click to pause."
end if
end sub

  
main 
.....
while holdflag
  doevents
went[/B]
 

Users who are viewing this thread

Back
Top Bottom