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.

If and Else

If and Else - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

If and Else

- [Instructor] In this video, we'll look at the if statement, and we'll look at if, if else, and if else if. Along the way, we'll also look at some comparison operators, and we'll look at some assignment operators. This is the problem we're trying to solve, is we're going to generate a random odd number, and then based of a conditional, put it in one of these three columns. If it's less than 100, it goes in the leftmost column, if it's greater than 300, it goes in the rightmost column, and if it's any other number, it goes in the center column. The first code example will go in the if button handler, so I'll double-click on this in the designer, and that takes us over to the handler in the VB code. I've already written a couple lines of code. On line seven, I'm declaring a variable and getting a random odd number from a random number generator, a value between zero and 401, and then I'm outputting the information to the text…

Contents