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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exit more than one loop

Status
Not open for further replies.

RycherX

Programmer
Mar 18, 2002
20
0
0
US
How do I exit 2 loops?
I want to be able to exit the Do loop and the outer For loop. Is that possible? How do I do that?

For i = i To UBound(tContents)
s = Trim(tContents(i))
'Check for end of file
If Mid(s, 1, 5) = "*SPC*" Then
ReDim BlockList(30)
Do
BlockList(BlockLines) = s
BlockLines += 1
i += 1
s = Trim(tContents(i))
Loop Until (Mid(s, 1, 5) = "*SPC*")
i -= 1 'Makes sures that I am at the line before the next BLOCK
End If
 
Yes, you can use the Exit Do and Exit For calls.

Hope this helps

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Before you exit you're inner loop, set i = UBound(tContents), so the the outer loop is satisfied.

 
For future reference, post VB.NET questions in the VB.NET forum796
 
bjd4jc - Took me a while to spot VB.Net specific code after I saw your post [smile]

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top