And Then Operator
Returns “false” if one or more Boolean expressions are false, but stops after the initial false expression.
Syntax
expression_1 And Then expression_2
Parts
expression_1- A Boolean expression.
expression_2- A Boolean expression.
Instructions
The result has the type Boolean.
And Then is almost the same as the operator And.
They are different when expression_1 is false.
When this occurs, expression_2 is not calculated.
This is correct because if one expression is false, the result is always false.
This is known as short-circuit evaluation.
If expression_1 is |
And expression_2 is |
Then the result is |
|---|---|---|
| True | True | True |
| True | False | False |
| False | not calculated | False |
Examples
Example 1
In this example, “parts” was supplied by the user.
If parts > 0 And Then all / parts >= minimum Then
' do something
End If
Example 2
If #h Is Object And Then #h.SomeMethod() Then
' do something
End If