A For Next Loop is just a shortcut of writing a long list of statements. Because each group of statements in such a list would do essentially the same thing, VB lets you define just one group of statements and request that it would be executed as many times as you want.
In a For Next Loop, start and end determine how long the loop runs
Check the syntax below:
for your_variable = start To end
code block
or
statements to be repeated
Next your_variable
Example:The following For Next Loop sounds four beeps in rapid succession from the computer's speakers:
For x = 1 To 4
Beep
Next x
so the output of that would be:
Beep
Beep
Beep
Beep
Based from the book Step by Step Microsoft Visual Basic
No comments:
Post a Comment