Goto

You’re probably expecting an anti-Goto diatribe, but I don’t mind Goto at all. It has its uses, primarily with error traps. Because error handling is inherently unstructured, an unstructured feature like Goto fits right in. If you use Goto for any other purpose, however, chances are you’re writing bad code. The C version of Goto actually makes some code easier to read as well as more efficient, but that’s because C’s switch statement is less powerful than Basic’s Select Case. Old versions of Pascal needed Goto because they lacked Basic’s complete syntax for early exit from loops and procedures. Basic provides the tools for structured programming.

Nevertheless, a procedure containing Goto is hidden in at least one example in this book. I’m so ashamed of myself for not devising a clearer way to write this code that I’m not going to point it out. A free bucket of bits to the first person who finds it and tells me how I should have written the procedure.

One minor hole in the Visual Basic looping structure is the lack of a Continue statement. Other languages offer a way to jump from the middle of a loop to continue with the next iteration. Basic only lets you jump completely out of the loop. You can work around this annoying limitation with Goto, but you shouldn’t have to.