|
|
Finally, VB will have a Continue StatementAfter A Decade +, Coming in VB 2005 | | The number one reason (IMHO) for using a GoTo in VB was the lack of a Continue Statement. VB 2005 has a Continue Statement, which can do away with the GoTo, which so many have complained about. Practically every other language that I have used, at least in recent years, has one. C, C++, Clipper, and I have forgotten my Cobol and Fortran, so I won't comment on them.
For years, many VBers including myself have lamented over the lack of Continue and the consequences (using a GoTo) and wondering why it was ever left out of the language. Of course, many still held contempt for anyone using the GoTo regardless of the reason. Being a pragmatist, rather than a purist, I never joined that group. Also having programmed in Cobol and Fortran, before there was a C++, Clipper, or VB, or even Basic for that matter, we used GoTo and even computed gotos. For that matter, showing my years, I programmed Jump instructions in machine code before there was an assembler, and Structured Programming in Compilers was a pipe dream.
So much for rambling! VB developers, take heart! Continue is coming in VB 2005 in three different forms. Consider the following code.
Dim jobs() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
For Each i As Integer In jobs
if i = 5 then Continue For ' skips to next iteration of for
' else we continue thru the loop
' with code
' now we have a do loop nested
Do
' do something
if i = 7 then Continue Do ' skip to next iteration of Do
' else go on with the code in the Do Loop
' .....
' now, put a While loop in for good measure
While i < 9
if i = 8 then Continue While ' skips to next iteration of While
' else keep coding....
End While
Loop
Next
| In VB.NET or earlier versions of VB, assuming this were a long loop, and could not easily be kept structured, I would probably have used GoTo and thought nothing of it, much to the chagrin of purist. But, I will gladly give up the GoTo for a Continue. Hurry up MS!
|
|