GoTo Statements

One of the easiest ways to change the flow of a program is to use a GoTo statement.
This statement transfers the program execution to a new line of code which is identified by a line label.
The only time you should really use this method though is for error handling.


Programs that use GoTo statements jump around and are extremely difficult to debug.
GoTo can cause your code to loop back and forth in ways that are difficult to follow.
If your code makes use of the GoTo statement the resulting flow is often referred to as "spaghetti code"
Most experienced programmers will never use the GoTo statement.

Public Sub Procedure_Name() 
   Dim iValue as Integer

   iValue = 20
   If iValue = 10 Then GoTo LineLabel
   Exit Sub
LineLabel:

End Sub


© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext