lang • labels

Labels

Identifier :

A label indicates a target for the GOTO instruction.

A label is local to a function or procedure.

GOTO and labels can be used to leave a control structure.

FOR iY As Integer = 0 TO 5
  FOR iX As Integer = 0 TO 20 STEP 1
    PRINT "Loop1 "; iX
      IF iX = 3 THEN GOTO LOOP2
    NEXT
  NEXT
LOOP2:

But GOTO and labels cannot be used to enter a control structure. This is forbidden, even if the variables are preset.

Dim iX As Integer = 18
' GOTO LOOP3   ' forbidden
FOR iX = 20 TO -2 STEP -2
LOOP3:
  PRINT "Loop2 "; iX
NEXT

See also