Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using of AndAlso
Message
From
01/09/2011 11:32:55
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01522454
Message ID:
01522480
Views:
32
>>>Take a look here
>>>http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/andalso-and-orelse
>>
>>Yes, but in the example I gave, And would have done it as well, correct?
>
>If the first condition is false, we don't need to evaluate the second. AndAlso only evaluates the second condition if the first is true. According to the linked article, both conditions will be evaluated if you used And. In other words, it seems we always want to use AndAlso in VB.NET instead of And

Not *always* :-}
Consider:
Dim i As Integer = 0
While True
	If (i > 10) AndAlso (System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1) > 10) Then
		Exit While
	End If
End While
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform