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 - Visual Basic Tutorial
From the course: Visual Basic Essential Training
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
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Explore the arithmetic operators3m 24s
-
(Locked)
Explore the comparison and logical operators5m 56s
-
(Locked)
If and Else5m 16s
-
(Locked)
Use the And, Or logical operators3m 13s
-
(Locked)
Use AndAlso, OrElse for better performance2m 48s
-
(Locked)
Select Case3m 30s
-
(Locked)
Challenge: Logic statements and string compare1m 50s
-
(Locked)
Solution: Logic statements and string compare3m 16s
-
(Locked)
-
-
-
-