Not

From Xojo Documentation

Operator

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

Usage

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.

Notes

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:

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

a = True

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

Using Not with numeric values:

Var i As Integer = 255

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

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

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

See Also

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