Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exiting a For Each Next loop

Status
Not open for further replies.

AWEinCA

Programmer
Oct 18, 2000
35
US
I have:

For Each <file> in <directory>
'Find InStr(&quot;text&quot;,<file>)
Next

Once I find the &quot;text&quot; in the <file> name. I want to stop looping through the <file>s in the <directory>.

You know...like a while loop...except for folder and file objects.

Is there a way I can exit the loop or use some kind of a bolContinue variable to stop looping?

Thanks for any help you can give.

Aaron
 
sure plug in exit for

ex:
for i 0 to somthing
if bolExit then
exit for
else
'do code
end if
next
 
use &quot;exit for&quot; like

For Each <file> in <directory>
'Find InStr(&quot;text&quot;,<file>)
if textFound then
exit for
end if
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top