|
-
Aug 3rd, 2008, 05:43 PM
#1
Thread Starter
PowerPoster
[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
-
Aug 3rd, 2008, 05:46 PM
#2
Re: boAbort = True stop a loop??
What kind of a loop is it? Do? For? You have:
Code:
Exit Do
Exit For
...
-
Aug 3rd, 2008, 05:50 PM
#3
Thread Starter
PowerPoster
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
-
Aug 3rd, 2008, 07:44 PM
#4
Thread Starter
PowerPoster
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.
-
Aug 3rd, 2008, 07:46 PM
#5
Re: boAbort = True stop a loop??
 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.
-
Aug 3rd, 2008, 07:55 PM
#6
Thread Starter
PowerPoster
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.
-
Aug 3rd, 2008, 08:06 PM
#7
Re: boAbort = True stop a loop??
 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
-
Aug 3rd, 2008, 08:11 PM
#8
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|