\<bookmark_value\>AND operator (logical)\</bookmark_value\>

AND Operator

Logically combines two expressions.


Result = Expression1 And Expression2


\<emph\>Result:\</emph\> Any numeric variable that records the result of the combination.

\<emph\>Expression1, Expression2:\</emph\> Any expressions that you want to combine.

Boolean expressions combined with AND only return the value \<emph\>True\</emph\> if both expressions evaluate to \<emph\>True\</emph\>:

\<emph\>True\</emph\> AND \<emph\>True\</emph\> returns \<emph\>True\</emph\>; for all other combinations the result is \<emph\>False\</emph\>.

The AND operator also performs a bitwise comparison of identically positioned bits in two numeric expressions.


Sub ExampleAnd
Dim A As Variant, B As Variant, C As Variant, D As Variant
Dim vVarOut As Variant
    A = 10: B = 8: C = 6: D = Null
    vVarOut = A > B And B > C REM returns -1
    vVarOut = B > A And B > C REM returns 0
    vVarOut = A > B And B > D REM returns 0
    vVarOut = (B > D And B > A) REM returns 0
    vVarOut = B And A REM returns 8 due to the bitwise AND combination of both arguments
End Sub

Please support us!