June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Section 6.2 presented the essentials of counter-controlled repetition with the While statement. Visual Basic also provides the For...Next repetition statement, which specifies the counter-controlled repetition details in a single line of code. To illustrate the power of For...Next, we rewrite the program of Fig. 6.1 using the For...Next statement in Fig. 6.2.
1 ' Fig. 6.2: ForCounter.vb 2 ' Using the For...Next statement for counter-controlled repetition. 3 Module ForCounter 4 Sub Main() 5 ' initialization, repetition condition and 6 ' incrementing are all included in For...Next statement 7 For counter As Integer = 2 To 10 Step 2 |
Read now
Unlock full access