VB.Net Tutorial/Statements/Continue — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:40, 26 мая 2010
Continue Do
public class Test
public Shared Sub Main
Dim j As Integer
For i As Integer = 1 To 3
j = 0
Do While j < 3
j += 1
For k As Integer = 1 To 3
Dim test1 As Boolean = k = 2
If test1 Then Continue For " Continues the For K loop.
Dim test2 As Boolean = i = j
If test2 Then Continue Do " Continues the Do.
Console.WriteLine(i & ", " & j & ", " & k)
Next k
Loop
Next i
End Sub
End class
1, 2, 1 1, 2, 3 1, 3, 1 1, 3, 3 2, 1, 1 2, 1, 3 2, 3, 1 2, 3, 3 3, 1, 1 3, 1, 3 3, 2, 1 3, 2, 3
Continue For
Option Strict On
Public Module ContinueStatement
Public Sub Main()
For ctr As Integer = 1 to 100
If ctr Mod 2 = 1 Then
Console.Write("{0} is odd", ctr)
Else
Console.WriteLine("{0} is even.", ctr)
Continue For
End If
If ctr Mod 3 = 0 Then
Console.Write(" and it is divisible by 3")
End If
If ctr Mod 5 = 0 Then
Console.Write(" and it is divisible by 5")
End If
If ctr Mod 7 = 0 Then
Console.Write(" and it is divisible by 7")
End If
Console.WriteLine()
Next
End Sub
End Module
1 is odd 2 is even. 3 is odd and it is divisible by 3 4 is even. 5 is odd and it is divisible by 5 6 is even. 7 is odd and it is divisible by 7 8 is even. 9 is odd and it is divisible by 3 10 is even. 11 is odd 12 is even. 13 is odd 14 is even. 15 is odd and it is divisible by 3 and it is divisible by 5 16 is even. 17 is odd 18 is even. 19 is odd 20 is even. 21 is odd and it is divisible by 3 and it is divisible by 7 22 is even. 23 is odd 24 is even. 25 is odd and it is divisible by 5 26 is even. 27 is odd and it is divisible by 3 28 is even. 29 is odd 30 is even. 31 is odd 32 is even. 33 is odd and it is divisible by 3 34 is even. 35 is odd and it is divisible by 5 and it is divisible by 7 36 is even. 37 is odd 38 is even. 39 is odd and it is divisible by 3 40 is even. 41 is odd 42 is even. 43 is odd 44 is even. 45 is odd and it is divisible by 3 and it is divisible by 5 46 is even. 47 is odd 48 is even. 49 is odd and it is divisible by 7 50 is even. 51 is odd and it is divisible by 3 52 is even. 53 is odd 54 is even. 55 is odd and it is divisible by 5 56 is even. 57 is odd and it is divisible by 3 58 is even. 59 is odd 60 is even. 61 is odd 62 is even. 63 is odd and it is divisible by 3 and it is divisible by 7 64 is even. 65 is odd and it is divisible by 5 66 is even. 67 is odd 68 is even. 69 is odd and it is divisible by 3 70 is even. 71 is odd 72 is even. 73 is odd 74 is even. 75 is odd and it is divisible by 3 and it is divisible by 5 76 is even. 77 is odd and it is divisible by 7 78 is even. 79 is odd 80 is even. 81 is odd and it is divisible by 3 82 is even. 83 is odd 84 is even. 85 is odd and it is divisible by 5 86 is even. 87 is odd and it is divisible by 3 88 is even. 89 is odd 90 is even. 91 is odd and it is divisible by 7 92 is even. 93 is odd and it is divisible by 3 94 is even. 95 is odd and it is divisible by 5 96 is even. 97 is odd 98 is even. 99 is odd and it is divisible by 3 100 is even.