[VB.NET]Do WHile文でExit Do を使うサンプル

書式

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Do While 条件式
If 条件式 Then
Exit Do
End if
Do While 条件式 If 条件式 Then Exit Do End if
Do While 条件式
If 条件式 Then
   Exit Do
  End if

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Sub Main()
'変数cftの定義
Dim cft As Integer = 15
'Do While
Do While cft < 25
'If条件式
If cft = 19 Then
'Exit Doを使用
Exit Do
End If
Console.WriteLine(cft)
cft = cft + 2
Loop
Console.ReadKey()
End Sub
End Module
Module Module1 Sub Main() '変数cftの定義 Dim cft As Integer = 15 'Do While Do While cft < 25 'If条件式 If cft = 19 Then 'Exit Doを使用 Exit Do End If Console.WriteLine(cft) cft = cft + 2 Loop Console.ReadKey() End Sub End Module
Module Module1
    Sub Main()
        '変数cftの定義
        Dim cft As Integer = 15

        'Do While
        Do While cft < 25
            'If条件式
            If cft = 19 Then
                'Exit Doを使用
                Exit Do
            End If
            Console.WriteLine(cft)
            cft = cft + 2
        Loop

        Console.ReadKey()
    End Sub
End Module

結果
15
17

VB.net

Posted by arkgame