Not Operator

See Also328LGX5              Example103H752>Low

Used to perform logical negation on an expression.


result = Not expr


The following table illustrates how result is determined:


If expr is       Then result is


True              False

False             True

Null1DDW7C0               Null


In addition, the Not operator inverts the bit values of any variable and sets the corresponding bit in result according to the following truth table:


Bit in expr     Bit in result


0                   1

1                   0


If an integer variable has the value 0 (False), the variable becomes -1 (True); if it has the value -1, it becomes 0. 

See Also

Arithmetic OperatorsSH0K1B

Comparison OperatorsNRJZ1K

Concatenation Operators2MYTW1K

Logical Operators1CQVUTN

Operator Precedence23082A9


Not Operator Example

The example displays 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.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.


Sub Form_Click ()

   Dim A, B, Msg                         ' Declare variables.

   A = 10: B = 8                         ' Assign values.

   If Not A = B Then                     ' Evaluate expression.

      Msg = "A and B aren't equal."


      Msg = "A and B are equal."

   End If

   MsgBox Msg                            ' Display results.

End Sub