And Then Operator

Performs a logical conjunction with short-circuit evaluation.

Syntax

expression1 And Then expression2

Parts

expression1
Required Boolean expression
expression2
Required Boolean expression

Remarks

The result is of type Boolean.

The And Then operator closely resembles the And operator, except when the first operand evaluates as false. When this occurs, the second operand is not evaluated at all. This is valid behavior because the falseness of the operation can always be proven whenever the first operand is false. This is known as short-circuit evaluation. The following truth table summarizes this behavior.

If expression1 isAnd expression2 isThe result is
TrueTrueTrue
TrueFalseFalse
Falsenot evaluatedFalse

Examples

Listing
' "parts" was inputted by the user
If parts > 0 And Then whole / parts >= minimun Then
    ' do something
End If
Listing
If #h <> #Null And Then #h SomeMethod? Then
    ' do something
End If

See also