<< Prev        Next >>

ID : 3699

GoTo

Function

To jump to a label.

Syntax

GoTo label name

Guaranteed Entry

Label name
Designate a label name.

Description

The system jumps to a label designated in a label name.

Related Terms

On Error, label

Attention

Possible jump destination is only within the procedure range and the other procedures can not be a jump destination.

Example

'!TITLE "Unconditional Execution of Program Bifurcation"
' Display results in each label after magnitude determination of aaa and bbb
Sub Sample_GoTo

  Dim aaa As Integer
  Dim bbb As Integer

  aaa = 1
  bbb = 10

  ' Magnitude determination of aaa and bbb
  If aaa > bbb Then

    ' If aaa > bbb, jump to LABEL1
    Goto LABEL1

  ElseIf aaa < bbb Then

    ' If aaa < bbb, jump to LABEL2
    Goto LABEL2

  Else

    ' If aaa = bbb, jump to LABEL3
    Goto LABEL3

  End If

  Exit Sub

LABEL1:

  ' Display the determination result (aaa > bbb) on the message output window
  PrintDbg ( aaa & " > " & bbb )

  Exit Sub

LABEL2:

  ' Display the determination result (aaa < bbb) on the message output window
  PrintDbg ( aaa & " < " & bbb )

  Exit Sub

LABEL3:

  ' Display the determination result (aaa = bbb) on the message output window
  PrintDbg ( aaa & " = " & bbb )

  Exit Sub

End Sub

ID : 3699

<< Prev        Next >>