From Xojo Documentation


Used to perform logical negation of a Boolean expression or a bitwise Not operation on an integer expression.


result = Not expression

Part Description
result A boolean value if expression is a boolean or an integer value if expression is an integer.
expression Any valid boolean or Integer expression.


The Not operator is overloaded. If you pass a Boolean expression, Not returns the opposite of the Boolean value it evaluates to. If expression evaluates to True, Not returns False. If expression evaluates to False, Not returns True.

If you pass an integer value, Not performs a bitwise Not operation. It inverts the bit values of the integer expression and sets the corresponding bit in the result according to the following table.

Bit in Expression Bit in Result
0 1
1 0

Sample Code

Using Not with Boolean values:

Dim a As Boolean
Dim b As Boolean
Dim c As Boolean ' defaults to False

a = True

b = Not a ' b = False
b = Not c ' b = True

Using Not with numeric values:

Dim i As Integer = 255

Dim result As Integer
result = Not i ' result = -256

This example tests whether a FolderItem exists and displays a message if it doesn't.

Dim f As FolderItem
f = GetOpenFolderItem(FileTypes1.jpeg) // defined in the File Type Set editor
If Not f.Exists Then
MsgBox("The file " + f.NativePath + "doesn't exist.")
Else // document exists
End If
Exception err As NilObjectException
MsgBox("Invalid pathname!")

See Also

And, Or, Xor operators; Bitwise class; Operator_Not function.