_____________________________________________
How to use Loops of VB?
_____________________________________________
| Pre-test Loops: | |
| While c <>End While | Do Until c = 10
|
| Do While c <>Loop | For c = 2 To 10 Step 2
|
|
Post-test Loops: | |
| Do
c += 1 Loop While c <> | Do
c += 1 Loop Until c = 10 |
' Array or collection looping
Dim names As String() = {"Fred", "Sue", "Barney"}
For Each s As String In names
Console.WriteLine(s)
Next
' Breaking out of loops
Dim i As Integer = 0
While (True)
If (i = 5) Then Exit While
i += 1
End While
' Continue to next iteration
For i = 0 To 4
If i <>Continue For
Console.WriteLine(i) ' Only prints 4
Next
____________________________________________________________________
____________________________________________________________________
No comments:
Post a Comment