
186 Chapter 5 • .NET Programming Fundamentals
val = val + 5
ctr = ctr + 1
Loop Until val > 100 And ctr >= 10
In this example, the code always executes at least once because the condi-
tional is not evaluated until after the code inside the loop has executed.Also note
that you can use Loop While to execute until the condition is False. While
loops can be very powerful for performing complex operations.You can also nest
loops inside of each other.
For Loops
The For loop is similar to the While loop except in this case, you are executing
the code in the loop a fixed number of times.This is useful when reading or
writing to arrays (covered in the next section). ...