CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: doevents

  1. #1
    Join Date
    Aug 2001
    Posts
    28

    doevents

    i made a funtcio that conatains in the WHILE the DOEVENTS
    but when i need to write in my CANCEL BUTTON?


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: doevents

    You will need to add a boolean to you WHILE loop.

    Do While (X > 10) And Not(blnCancelPressed)
    ' some code
    DoEvents
    Loop



    The (X > 10) must be replaced by your condition. Then when the cancel button is pressed, set the blnCancelPressed to true, so you will exit the loop. Then after the loop, check if they pressed cancel, and exit. This must only be done if further processing comes after the loop. Make sure that blnCancelPressed is accessible from the two functions, so add it to the general declaration section of the module/form.

    ' Cancel Button
    private Sub cmdCancel_Click()

    blnCancelPressed = true

    End Sub

    private Sub SomeSub()

    blnCancelPressed = false

    Do While (X > 10) And Not(blnCancelPressed)
    ' some code
    DoEvents
    Loop

    If blnCancelPressed then Exit Sub

    ' Some Other Processing

    End Sub




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Aug 2001
    Posts
    28

    Re: doevents

    ok 10X, and whats about FOR ....but i want the button to cancel the for and not "end for"


  4. #4
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Re: doevents

    Could you please show me your code concerning your question, and tell me exactly what you are trying to do

    Thanks
    Hisham
    Thank You, Hisham

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

Featured