Logical

It is common to want to test whether two conditions are both true or only one is true or neither is true.


AND

if (objMyObject = null) & (bUpdate == false) 
{
}
If (objMyObject Is Nothing) And (bUpdate = False) Then 
End If

The second condition is only checked if the first one is true. This is often referred to as short circuiting.

if (objMyObject = null) && (bUpdate == false) 
{
}
If (myObject1 Is Nothing) AndAlso (myObject.Property = True) Then 
End If

OR

if (objMyObject = null) | (sFullName == "Russell") 
{
}
If (objMyObject Is Nothing) Or (sFullName = "Russell") Then 
End If

The second expression is only evaluated if the first expression is true. This is often referred to as short-circuit evaluation.

if (objMyObject = null) || (sFullName == "Russell") 
{
}
If (objMyObject Is Nothing) OrElse (sFullName = "Russell") Then 

End If


Exclusive OR

Exclusive Or. True if only one statement is true.

if (objMyObject = null) ^ (sFullName == "Russell") 
{
}
If (objMyObject Is Nothing) Xor (sFullName = "Russell") Then 
End If


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext