The GoTo statement
In VB, the GoTo
statement transfers control to a specific line or label within your code. While the GoTo
statement is generally discouraged in modern programming practices, it is still supported in Visual Basic for specific scenarios.
The basic syntax of the GoTo
statement in Visual Basic is as follows:
goto line_or_label
Here, line_or_label
refers to the line number or label you want to transfer control to. To see GoTo
usage, consider the following example:
Sub GotoProc() Dim num1 As Integer = 20 If num1 > 10 Then GoTo Label1 Else GoTo Label2 End If Label1: Console.WriteLine("The number is above 10.") GoTo EndLabel Label2: Console.WriteLine("The number is equal or under 10....