And Operator
Operator used to perform a logical or bitwise And of 2 expressions.
Syntax
result = expr1 And expr2
Parameters
- expr1, expr2
- For logical And, specify a value which returns a Boolean result. For bitwise And, an integer expression.
- result
- For logical And, a Boolean value is returned. For bitwise And, result is an integer.
Description
A logical And is used to combine the results of 2 or more expressions into 1 single Boolean result. The following table indicates the possible combinations.
expr1 | expr2 | result |
---|---|---|
True | True | True |
True | False | False |
False | True | False |
False | False | False |
A bitwise And performs a bitwise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:
If bit in expr1 is | And bit in expr2 is | The result is |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
See Also
LShift, Mask, Not, Or, RShift, Xor
And Operator Example
Function LogicalAnd(x As Integer, y As Integer)
If x = 1 And y = 2 Then
Print "The values are correct"
EndIf
Fend
Function BitWiseAnd()
If (Stat(0) And &H800000) = &H800000 Then
Print "The enable switch is open"
EndIf
Fend
>print 15 and 7
7
>