Results 1 to 6 of 6

Thread: Exit Loop (break event)

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    Thailand
    Posts
    13

    Question Exit Loop (break event)

    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.
    www_vb_ok

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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).

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    Thailand
    Posts
    13
    "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.
    www_vb_ok

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    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.

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width