Operator

# Not

<div class="rst-class">

forsearch

</div>

Operator

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to perform logical negation of a `Boolean</api/data_types/boolean>` expression or a bitwise <span class="title-ref">Not</span> operation on an `integer</api/data_types/integer>` expression.

## Usage

``` xojo
result = Not expression
```

| Part       | Description                                                                                                                                                                                                 |
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| result     | A `boolean</api/data_types/boolean>` value if *expression* is a `boolean</api/data_types/boolean>` or an `integer</api/data_types/integer>` value if *expression* is an `integer</api/data_types/integer>`. |
| expression | Any valid `boolean</api/data_types/boolean>` or `Integer</api/data_types/integer>` expression.                                                                                                              |

## Notes

The <span class="title-ref">Not</span> operator is overloaded. If you pass a `Boolean</api/data_types/boolean>` expression, <span class="title-ref">Not</span> returns the opposite of the `Boolean</api/data_types/boolean>` value it evaluates to. If *expression* evaluates to `True</api/language/true>`, <span class="title-ref">Not</span> returns `False</api/language/false>`. If *expression* evaluates to `False</api/language/false>`, <span class="title-ref">Not</span> returns `True</api/language/true>`.

If you pass an `integer</api/data_types/integer>` value, <span class="title-ref">Not</span> performs a bitwise <span class="title-ref">Not</span> operation. It inverts the bit values of the `integer</api/data_types/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 <span class="title-ref">Not</span> with Boolean values:

``` xojo
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 <span class="title-ref">Not</span> with numeric values:

``` xojo
Var i As Integer = 255

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

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This example tests whether a `FolderItem</api/files/folderitem>` exists and displays a message if it doesn't.

``` xojo
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!")
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`And</api/language/operators/bitwise_logical/and>`, `Or</api/language/operators/bitwise_logical/or>`, `Xor</api/language/operators/bitwise_logical/xor>` operators; `Bitwise</api/language/bitwise>` class; `Operator Not</api/language/operators/operator_overloads/operator_not>` function.

</div>
