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.

Exit or continue loops

Exit or continue loops

- [Instructor] There are two special keywords we can use to change the normal loop process. We can exit the loop early or we can skip one iteration of the loop, that is the exit keyword and the continue keyword. The way this demo's going to work is we're going to look through this value, this string value here, and I'm looking for a character. And when I find the character, I'm going to take one of these actions, exit or continue. This is what the code looks like. Here is how you use exit. I'm in a for loop, so I would say exit for. If I was in a do loop, then I would type in exit do. If I want to continue, then I change exit to continue. What I'm doing is I'm grabbing the string from the UI. I'm setting up a char, and then this bit of code is going to look through the string. Now there are better ways to do this. I'm only using this as an example of how to work with the for loop. The string class itself has better ways of doing what I'm showing you here. I want to point on something…

Contents