Visual Basic for Applications Reference

And Operator Example

This example uses the And operator to perform a logical conjunction on two expressions.

Dim A, B, C, D, MyCheck
A = 10: B = 8: C = 6: D = Null   ' Initialize variables.
MyCheck = A > B And B > C   ' Returns True.
MyCheck = B > A And B > C   ' Returns False.
MyCheck = A > B And B > D   ' Returns Null.
MyCheck = A And B   ' Returns 8 (bitwise comparison).
Show: