And - Operator (Bit comparison AND)

Concerns

This operator performs a bit-related AND comparison between two expressions to the left and right of the operator.

Example

Dim V1 As Long, V2 As Long, V3 As Long

V1 := 7

V2 := 2

V3 := (V1 AND V2)

Result:

V3 contains a value of 2

Declaration:

V1 contains a value from the set bits 1,2,3 = 1*2^0 + 1*2^1 + 1*2^2 = 1 + 2 + 4 = 7

V2 contains a value from the set bits 2 = 1*2^1 = 2

The logical comparison AND now compares the bits set together. This is bit 2, so the result is 1*2^1 = 2