ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Advancing to the next iteration of a loop? (https://www.excelbanter.com/excel-programming/326633-advancing-next-iteration-loop.html)

Maury Markowitz

Advancing to the next iteration of a loop?
 
I can't find any way to advance a loop in VB. It won't let you put a NEXT
anywhere by the bottom, and I can see anything like "continue" or "next for".
Is this feature really missing??!?

Maury

[email protected]

Advancing to the next iteration of a loop?
 
What kind of loop??? A Do/Loop??? Post an example of your code.


Jim Rech

Advancing to the next iteration of a loop?
 
You just have to do something like this:

Sub a()
Dim Counter As Integer
For Counter = 1 To 10
If Counter = 5 Then GoTo NextLoop
Debug.Print Counter
NextLoop:
Next
End Sub


--
Jim
"Maury Markowitz" wrote in
message ...
|I can't find any way to advance a loop in VB. It won't let you put a NEXT
| anywhere by the bottom, and I can see anything like "continue" or "next
for".
| Is this feature really missing??!?
|
| Maury



Maury Markowitz

Advancing to the next iteration of a loop?
 
"Jim Rech" wrote:
You just have to do something like this:


Ewwwwww. No wonder people whine about this language.

Well the good news is I wasn't just being dumb.

Maury


Tushar Mehta

Advancing to the next iteration of a loop?
 
How's a 'Continue' or a 'Next for' or whatever any better than a goto?
All of them violate the basic premise of good programming: every block
of code must have a single entrypoint and a single exit point. One can
always use If...Then block. If the nested code is reasonably large use
or more subroutines.

Every language has its own set of compromises and limitations. If one
is so inclined there is something to whine about *every* language ever
developed. ;-)

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
"Jim Rech" wrote:
You just have to do something like this:


Ewwwwww. No wonder people whine about this language.

Well the good news is I wasn't just being dumb.

Maury




All times are GMT +1. The time now is 01:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com