Vb.net-continue-statement

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

VB.Net-声明を続ける

Continueステートメントにより、ループは本体の残りの部分をスキップし、反復する前にその状態をすぐに再テストします。 Exitステートメントのように機能します。 強制的に終了する代わりに、ループの次の反復を強制的に実行し、その間のコードをスキップします。

For …​ Nextループの場合、Continueステートメントは条件付きテストを実行し、ループの増分部分を実行します。 WhileおよびDo …​ Whileループの場合、continueステートメントにより、プログラム制御が条件付きテストに渡されます。

構文

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

Continue { Do | For | While }

流れ図

VB.Net continueステートメント

Module loops
   Sub Main()
      ' local variable definition
      Dim a As Integer = 10
      Do
         If (a = 15) Then
            ' skip the iteration '
            a = a + 1
            Continue Do
         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