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.

If and else statements

If and else statements

- [Instructor] In this video, we'll look at the if statement and explore its keywords, if, else, and else if. Along the way, we'll look at some of the comparison operators, and we'll look at some assignment operators. The problem we're solving is to generate a random number, and based on a conditional, place it in one of these three columns. If the number is less than 100, it goes in the leftmost column. If it's greater than 300, it goes in the rightmost column, and any other number goes in the center column. So, the code for the if statement will go in this button, if else will go in this middle button, and the else if will go in this third button. I have already written some code, you can see it here at the top of this event procedure. I'm declaring an integer variable, the number generator, I'm getting an odd number up to 401, and then I'm assigning it to this current random output text box. There's actually four text boxes I'm using in this example. The one I'm assigning to in…

Contents