Results 1 to 8 of 8

Thread: [RESOLVED] boAbort = True stop a loop??

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [RESOLVED] boAbort = True stop a loop??

    hey guys I am using findfilefirst and I loop it to scan a list of all drives on a computer..

    However when I stop, by using boAbort = True

    it stops that instance,but the loop keeps going, so if it was scanning c:\ boAbort = True would stop that loop, but then it starts on D: and etc.

    Is there a way to get it to stop the loop and stop alltogether?

    Thank you

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: boAbort = True stop a loop??

    What kind of a loop is it? Do? For? You have:
    Code:
    Exit Do
    Exit For
    ...

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: boAbort = True stop a loop??

    Its
    Dim ixz As Long

    For ixz = 0 To List8.ListCount - 1
    Text1.Text = List8.List(ixz)


    '''very VERY long code

    next

    ok thanks I will try EXIT FOR

    EDIT: I just did, and get the error

    exit for not within for..next

    and the stoop button code is this..

    Private Sub Image1_Click()
    List8.Clear
    Text1.Text = ""
    boAbort = True
    Exit For
    Text28.Text = "OFF"
    Image8.Visible = True




    End Sub

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: boAbort = True stop a loop??

    hmmm does this mean the exit for has to be in the loop?

    Is it possible to exit it outside of the loop?

    i have one button that when pressed starts the loop , i would like another button that when pressed stops the loop

    it may be hard becuase there is one loop inside another loop.

  5. #5
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: boAbort = True stop a loop??

    Quote Originally Posted by Justin M
    hmmm does this mean the exit for has to be in the loop?

    Is it possible to exit it outside of the loop?

    i have one button that when pressed starts the loop , i would like another button that when pressed stops the loop

    it may be hard becuase there is one loop inside another loop.
    You can't use "Exit For" outside the loop.

    Set a flag you can monitor, maybe something like,

    For ixz = 0 To List8.ListCount - 1
    If boAbort = True then Exit For
    '''very VERY long code
    next

    Private Sub Image1_Click()
    boAbort = True
    ''''rest of code
    End Sub

    Depending how you code you may need to add a DoEvents command in your loops so buttons respond to clicks when the loops are running.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: boAbort = True stop a loop??

    thats perfect, thank you.

    However, it does stop the loop and and ends the scan, but not I can't start it up again.

    So once I press the stop button, the scan button does not do anything now.

  7. #7
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: boAbort = True stop a loop??

    Quote Originally Posted by Justin M
    thats perfect, thank you.

    However, it does stop the loop and and ends the scan, but not I can't start it up again.

    So once I press the stop button, the scan button does not do anything now.
    At the top of your scan button code reset the flag , boAbort = False

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: boAbort = True stop a loop??

    OMG THats AWESOME!!!!

    thank you so much!!!!!!!!!!

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