
Beginning ASP.NET 2
.0.pdf





Chapter 9
active connection, so the Close would fail. This is where the Is and IsNot tests are used, so the Close could be modified to
If conn IsNot Nothing Then conn.Close()
End If
If an error occurs, conn wouldn’t be assigned a value and would be Nothing, so conn is tested before being closed. If it is not Nothing (I’m sure the editors are having a fit about all these double negatives), the connection can be closed. You’ll see more about this topic in Chapter 15.
Logical Operators
Logical operators allow the combination of expressions. The operators are as follows:
Operator |
Action |
|
|
And |
True if both sides of the expression are true |
Or |
True if one side of the expression is true |
Xor |
True if only one side of the expression is true |
AndAlso |
Short-circuited version of And |
OrElse |
Short-circuited version of Or |
Not |
Negates the expression |
|
|
All except Not require two expressions, in the following form:
LeftExpression Operator RightExpression
The following table should make the result more obvious:
Operator |
LeftExpression |
RightExpression |
Result |
|
|
|
|
And |
True |
True |
True |
|
True |
False |
False |
|
False |
True |
False |
|
False |
False |
False |
Or |
True |
True |
True |
|
True |
False |
True |
|
False |
True |
True |
|
False |
False |
False |
|
|
|
|
314



