From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Use Do loops to run code until a condition is fulfilled

Use Do loops to run code until a condition is fulfilled - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Use Do loops to run code until a condition is fulfilled

- [Instructor] The do loop is used when a loop must run continuously until a specific condition is satisfied. Then the loop ends. We've seen the do loop earlier in the course when I created a console application that ran endlessly until the correct key was entered on the keyboard. There are four variations of the do loop, which I'm demonstrating here in the endless loop method. All the variations start with the word do here on line 21 and end with the word loop. We then write a test condition to control when the loop ends. The test condition can be placed either at the end of the loop as shown here in these first two examples, or at the beginning of the loop like you see here on line 31 and on line 36. So the way this would work is it's going to start here. It'll run all the code in this section of the do loop and then when it gets to here, it's going to check this condition. It's going to loop while this condition is true. So if this is true and the expression here is true, then…

Contents