Now, we will see how to use GoTo statement in the Select-Case statement with an example. In visual basic, we can use the GoTo statement to exit from the defined loops or transfer the control to the specific Select-Case label or the default label in the Select statement based on our requirements. Visual Basic Goto Statement with Select Statement If you observe the above result, whenever the variable ( i) value equals 5, the GoTo statement transfers the program control from for loop to the specified label statement ( endloop) position. We will get the following result when we execute the above visual basic program. If you observe above example, we used GoTo statement in for loop with labeled statement “ endloop” to exit for loop and transfer the program execution to the defined label statement whenever the variable ( i) value equals 5. Console.WriteLine("Press Enter Key to Exit.")
0 Comments
Leave a Reply. |