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

Use AndAlso, OrElse for better performance - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

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