top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is difference between "And" and "AndAlso" in VB.NET?

+4 votes
1,260 views
What is difference between "And" and "AndAlso" in VB.NET?
posted Jan 6, 2014 by Atul Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

And operator will check all conditions in the statement before continuing, whereas the Andalso operator will stop if it knows the condition is false. For example:

if x = 5 And y = 7

Checks if x is equal to 5, and if y is equal to 7, then continues if both are true.

if x = 5 Andalso y = 7

Checks if x is equal to 5. If it's not, it doesn't check if y is 7, because it knows that the condition is false already. (This is also called short-circuiting)

Source: http://stackoverflow.com/questions/302047/what-is-the-difference-between-and-and-andalso-in-vb-net

answer Jan 6, 2014 by Luv Kumar
...