Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

VB - Manually stop a do while loop

  • 13-07-2008 7:30pm
    #1
    Registered Users, Registered Users 2 Posts: 938 ✭✭✭


    Wonder if anyone can help me with this, I need to try and stop a do while loop manually, I have one button to start the loop and another to stop it. I have tried this

    Do while button_Start.enabled = false
    .....
    Loop

    In the stop button event I have set button_start.enabled = True but
    this just causes the application to stop responding and doesn't exit.


Comments

  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    This isn't VB specific, but could you not make the while not true?

    e.g.

    Do {

    whatever

    } while(x>0)

    Just make x equal 0 or less than 0.


  • Registered Users, Registered Users 2 Posts: 5,238 ✭✭✭humbert


    While not button.enabled
    ...
    end while

    should be working, sure the code isn't getting suck somewhere inside the loop?


  • Registered Users, Registered Users 2 Posts: 2,152 ✭✭✭dazberry


    The stop button event isn't firing because the message loop isn't being processed because you're locked into the while loop (remember that Win32 GUI is single threaded). VB has something like a DoEvents call (in Delphi its Application.ProcessMessages) - if you put this in your while loop your stop button event should then fire.

    D.


  • Registered Users, Registered Users 2 Posts: 5,238 ✭✭✭humbert


    Ah, good call. Should have spotted that!


  • Registered Users, Registered Users 2 Posts: 938 ✭✭✭logic


    Thanks Dazberry, that done the trick. I had seen do events before in some one elses code but didn't understand what it did.


  • Advertisement
Advertisement