Results 1 to 4 of 4

Thread: Abort loop when hitting command button

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Location
    London, UK
    Posts
    145
    Hello!
    In my app I'm using a rather slow loop, which takes a lot of time. I'm using a form with a progressbar to show how much time it's left, but I would like to have a commandbutton which the user could press to abort the loop -a cancel button.

    I'm not sure how to do this, since pressing a button triggers a new event, and my app is bussy carriyng out the event with the loop.

    If you know how to do this, please help me!
    Pentax
    Wilhelm Tunemyr,
    Swede in London

    [email protected]

    "Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
    Heinrich Heine (1797-1856)

    Pravda vítezi!
    (Truth prevails!)

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

  3. #3
    Junior Member
    Join Date
    Aug 2000
    Location
    The Glove state
    Posts
    28

    Cool Yo

    Look at this old loop for your anwser
    Always let the Wookiee Win!

  4. #4
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Just thought I'd give an alternative that's similar in concept: this one shows a loop displaying a countdown and stops when the user hits escape
    Code:
    Option Explicit
    Dim lCntr As Long
    
    Private Sub Command1_Click()
        lCntr = 100000
        Do While lCntr > 0
            lCntr = lCntr - 1
            Label1 = lCntr
            DoEvents
        Loop
    End Sub
    
    Private Sub Command2_Click()
    lCntr = 0
    End Sub
    Wade

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