contents.gifindex.gifprev1.gifnext1.gif

Not Operator

Purpose

Used to negate a numeric expression.

Syntax

result = Not expr

Notes

The following table illustrates how result is determined.

If expr is
Then result is


true (nonzero)
False (0)
false (0)
True (-1)
Null
Null


The Not operator performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following truth table.

Bit in expr
Bit in result


0
1
1
0


The Not operator inverts the bit values of any variable. If an integer variable has the value 0 (False), the variable becomes -1 (True); if it has the value -1, it becomes 0. However, a bit-wise Not comparison can be performed only in Access Basic.

Example

This example prints a message that depends on the value of variables A and B, assuming neither variable is a Null. If A = 10 and B = 8, the Not expression evaluates True because A is not equal to B.

If Not A = B Then

Debug.Print "A and B aren't equal."

Else

Debug.Print "A and B are equal."

End If