Vb.net-goto-statement

提供:Dev Guides
移動先:案内検索

VB.Net-GoToステートメント

GoToステートメントは、プロシージャ内の特定の行に無条件で制御を移します。

GoToステートメントの構文は次のとおりです-

GoTo label

流れ図

VB.Net gotoステートメント

Module loops
   Sub Main()
      ' local variable definition
      Dim a As Integer = 10
Line1:
      Do
         If (a = 15) Then
            ' skip the iteration '
            a = a + 1
            GoTo Line1
         End If
         Console.WriteLine("value of a: {0}", a)
         a = a + 1
      Loop While (a < 20)
      Console.ReadLine()
   End Sub
End Module

上記のコードをコンパイルして実行すると、次の結果が生成されます-

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19