From the course: Visual Basic Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Listen for KeyChar to terminate loop

Listen for KeyChar to terminate loop - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Listen for KeyChar to terminate loop

- The first change we're going to make is to stop this counter from incrementing forever. So after this line of code, I'll use an if statement, so I'll type in if, and then press the Tab key, and that causes Visual Studio to stub in the rest of the code. So I'll say, if counter is greater than, pick a number here, let's say it's greater than 30, then do the code that's inside the if statement. And what I want to do is reset the counter back to the initial number. So we started with two, so I'll set it back to two here. Then I'll see what it looks like when we run. When it gets to 30, it starts over. Only thing I'll do, I don't need to keep seeing this dianostics window in the back, so I'll switch over to Visual Studio and close this. Then it won't pop up the next time I run the application. Another change I'd like to make is this Loop While. I'd like to let the user exit the loop when they are ready.…

Contents