Prev | Current Page 73 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

WriteLine("{0}", Item.ToString())
Next
nNote Modifying an iterator variable, or passing it to a method, can make your code difficult to read and
debug. You should treat the iterator variable as read-only.
CHAPTER 2 n VB 2008 SYNTAX 31
Finally, the Exit For statement is used if you reach a condition in which you want to terminate
execution of the loop early. Control then passes to the statement following the Next
statement.
For . . .Next
The For . . . Next construct is used to loop over items in a group, and you define the number
of times the loop iterates by use of an expression. The basic For. . . Next syntax looks like this:
For counter As datatype = start To end
statements
Exit For
Next counter
You can declare the counter variable inline, which is a nice feature comparable with C#.
The For counter expression evaluates to a Boolean, and each time it??™s true, the subsequent
statements are executed. If you want to exit the loop before the expression evaluates to False,
use the Exit For statement:
For i As Integer = 0 To 10
Console.WriteLine("{0}", i.ToString)
Next i
Do While and Do Until
While the For . . . Next statement iterates based on a known number of times or a number
derived from a count of something, Do While and Do Until execute statements until a certain
condition is either true or false.


Pages:
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
dieta light pensjonaty w beskidach życzenia ślubne katalog stron oferty