Click to See Complete Forum and Search --> : Exit Loop (break event)
www_vb
Oct 10th, 2002, 11:49 PM
If I want to exit loop (ex. for loop)
by click button event
and get data from loop
Can I use any event to break current loop.
Thank you very much for all answer.
Edneeis
Oct 11th, 2002, 12:05 AM
You can use a flag. Set a boolean value to false and in the loop check for it during each loop and if it changes to true the exit the loop. Then in the button have it change the boolean to true. Inorder for the button to be able to be pressed while the loop is running you'll need to start a new thread or in some way run it asynchronously, which may mess up the flag (not sure).
www_vb
Oct 11th, 2002, 02:43 AM
"Inorder for the button to be able to be pressed while the loop is running you'll need to start a new thread or in some way run it asynchronously, which may mess up the flag (not sure). "
I don't understand this sentence please advice this above
step by step. Please help me again.
Edneeis
Oct 11th, 2002, 03:46 AM
Well if you are looping then your program isn't free to process or accept other things like a button press. So you have loop in another thread or something to let the program still go on as normal and not be slowed down by the loop. I mean you can just stuck Application.DoEvents() in the loop but then it is still sluggish.
powdir
Oct 11th, 2002, 08:53 AM
if you dont want to bother with multithreading or async loops you could do your processing in a timer_tick event, by pressing a button you would set the timer's enables status to false - might not be suitable for you in this case but worth remembering.
Edneeis
Oct 11th, 2002, 10:18 AM
I saw this and thought of you:
http://www.vbcity.com/forums/topic.asp?tid=12456
*Sorry for the mutiny of a post to another forums*
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.