Visual Basic Fundamentals for Absolute Beginners: (09) For..Next Iterations

Play Visual Basic Fundamentals for Absolute Beginners: (09) For..Next Iterations
Sign in to queue


Iterations allow our applications to loop through a block of code until a condition is satisfied. We'll cover several different types of iteration statements throughout this series, but we'll start with the for iteration statement. I'll demonstrate how to utilize "code snippets" to help remind you of the syntax for this complex statement, and will demonstrate debugging in action as we watch the values of our loops displayed in the Visual Studio IDE in several ways.

Full course outline:



Download this episode

Download captions

The Discussion

  • User profile image

    What's the difference between the use of the For..Next and Loop..Until statements?

  • User profile image

    @Shadolio: For Next is traditionally used when you want to go through a loop a specific number of times. You could accomplish the same thing in a Loop, but you'd have to declare the index variable and you'd have to increment it yourself. It does allow you some more flexibility (you could increment by 2 if a certain condition was met for example), but it also opens the door to an infinite loop if you forget to increment the counter or write your logic incorrectly. If you have a fixed number of loop iterations in mind, I'd use a For ... Next, if you want to loop until you find something or for a variable amount of time, then a Do Until ... Loop may be a better choice. Just make sure you always have a way out (if you hit the end of the file, or have been looping more than x times without hitting your expected condition, etc.)

  • User profile image

    hello seems this note with tab tab is enable by configuration i dont have it

Add Your 2 Cents