From the course: Visual Basic Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Use AndAlso, OrElse for better performance - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Use AndAlso, OrElse for better performance
- [Instructor] Visual Basic has two special short-circuit operators. I'll demonstrate the And/Also operator in this video. The other short-circuit operator is the Or/Else operator. You can substitute And/Also anywhere you'd use the AND operator. The same is true for Or/Else, it can replace the OR operator. The benefit for short-circuit operators is that they can help application performance. For example, And/Also does not evaluate the second expression when the first expression is false. This is useful when the second expression is slower or expensive to call. For example, look at this And button. When I click on this button, the if statement is going to run two functions, IsNetworkAvailable(), it's also going to run IsDatabaseOnline(). The second function is slow to run. When I clicked on the button, keep your eye down here, you'll see it's processing, and after about three seconds, I see the result. Here's the…
Contents
-
-
-
-
-
-
-
-
-
-
-
-
Explore the arithmetic operators3m 24s
-
Explore the comparison and logical operators5m 56s
-
If and Else5m 16s
-
Use the And, Or logical operators3m 13s
-
Use AndAlso, OrElse for better performance2m 48s
-
Select Case3m 30s
-
Challenge: Logic statements and string compare1m 50s
-
Solution: Logic statements and string compare3m 16s
-
-
-
-
-