VB.NET 繰り返し文For/For Each/Do/While構文

2011/09/28 15:24Update
TAGS: VB.NET | 繰り返し | For | ForEach | Do | While

VB.NET の繰り返し文For/For Each/Do/Whileの構文について

■For ~ Next    構文
For i = 0 To 9              '0, 1, 2, …, 8, 9
    'Exit For                  'Forループから脱出
    'Continue For          '飛ばして、次の周処理を続行
Next i


■For ~ Step ~ Next    構文
For i = 0 To 10 Step 2    '0, 2, 4, 6, 8, 10

Next i


■ForEach ~ Next    構文
For Each item As Object In items

Next


■Do ~ Loop    構文
Do
    If  boolean-expression Then
         Exit Do
         'Continue Do
    End
Loop


■Do ~ Until ~ Loop    構文
Do Until i > 100
    i = i + 1
Loop


■Do ~ Loop Until構文
Do
    i = i + 1
Loop Until i > 100


■Do ~ While    構文
Do While i < 100
    i = i + 1
    'Exit While
    'Continue While
Loop


■While ~ End While構文
Dim i As Integer = 0
While i < 20
    i += 1
    'Exit While
End While

.

有关作者
Syboos.jp編集長AJavaやオープンソース情報の執筆、Webサイトの開発や運営全般の業務に携わる。

Sponsored Link


Comments

用户名 (required)

Email (will not be published) (required)

URL

Evaluation