Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Content Obsolete

This content is no longer current. We recommend you try the following url for more up to date content: http://channel9.msdn.com/Series/Visual-Basic-Fundamentals-for-Absolute-Beginners

For . . . Next Iterations - 08

9 minutes, 19 seconds


Right click “Save as…”

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.

Download the source code For...Next Iterations


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • halit ateshalit ates

    First, I didn't understand 'for statement' covers which area.
    Moreover, In the first example 'exit for' is located inside if statement, how is the operation queue?

    Does it mean "never exit from 'for statement' unless 'if statement' is validated"?
    Should we follow statements line by line or when a statement begins it ends with an end point declaration?

  • halit ateshalit ates

    Sorry, I think I had found the answer about 'exit for' by making a simple test.
    It simply disrupts for statement and code continues from the line after 'next', and 'exit for' isn't also a must for such a statement, boundaries are defined with for statement anyway.

  • @halit ates:The "Exit For" statement jumps the code out of the "For Next" statement. Say that you need to evaluate whether a condition is true for thousands of values (For index = 1 to 1000000)  . If the value you are looking for is the first one that is evaluated and is true then without the "Exit For" statement your code would check the next 999999 values even though you have already found the value that you are looking for.  So basically the "Exit For" simply speeds up the execution of your software by "jumping over" all of the values that you do not need to evaluate. In older versions of basic you would have used a "GoTo" statement to do the same thing at the expense of adding one more line of code.

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.