DataType

# Boolean

<div class="rst-class">

forsearch

</div>

DataType

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

## Description

<span class="title-ref">Boolean</span> is an intrinsic data type. A <span class="title-ref">Boolean</span> can only take on the values of `True</api/language/true>` or `False</api/language/false>`. The default value is `False</api/language/false>`.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                             | Parameters                                | Returns | Shared |
|----------------------------------|-------------------------------------------|---------|--------|
| `FromString<boolean.fromstring>` | value As `String</api/data_types/string>` | Boolean | ✓      |
| `ToString<boolean.tostring>`     |                                           | Boolean |        |

## Method descriptions

<div id="boolean.fromstring">

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

</div>

<div class="rst-class">

forsearch

</div>

Boolean.FromString

**FromString**(value As `String</api/data_types/string>`) As Boolean

> Returns the value passed as a <span class="title-ref">Boolean</span>.
>
> This method is `shared</api/language/shared>`.
>
> If the value is `"True"`, then `True</api/language/true>` is returned, otherwise the `False</api/language/false>` is returned.
>
> This example sets a `Value<desktopcheckbox.value>` property of a `CheckBox</api/user_interface/desktop/desktopcheckbox>` to `True</api/language/true>` by passing the `String</api/data_types/string>` `True</api/language/true>` to the FromString function. This can be useful for setting <span class="title-ref">Boolean</span> values of classes such as `CheckBox</api/user_interface/desktop/desktopcheckbox>` from `Strings</api/data_types/string>` coming from files or databases.
>
> ``` xojo
> CheckBox1.Value = Boolean.FromString("True")
> ```

<div id="boolean.tostring">

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

</div>

<div class="rst-class">

forsearch

</div>

Boolean.ToString

**ToString** As Boolean

> Returns the value as a string.
>
> If the value is `True</api/language/true>`, the `String</api/data_types/string>` `"True"` is returned, otherwise the `String</api/data_types/string>` `"False"` is returned.
>
> This example displays "True" or "False" in the `MessageBox</api/user_interface/messagebox>` depending on whether the property is set to `True</api/language/true>` or `False</api/language/false>`.
>
> ``` xojo
> MessageBox(Window1.HasCloseButton.ToString)
> ```

## Notes

A <span class="title-ref">Boolean</span> is a variable that can have one of two values. In Xojo, the values are `True</api/language/true>` or `False</api/language/false>`. You can think of `True</api/language/true>` as the equivalent of Yes or On, whereas `False</api/language/false>` is equivalent to No or Off.

<span class="title-ref">Boolean</span> values are `False</api/language/false>` by default but can be set to `True</api/language/true>` using the `True</api/language/true>` keyword and back to `False</api/language/false>` using the `False</api/language/false>` keyword.

The `VarType</api/language/vartype>` function returns 11 when passed a <span class="title-ref">Boolean</span> variable.

## Sample code

Declares a <span class="title-ref">Boolean</span> variable and sets its value to `True</api/language/true>`:

``` xojo
Var isTaxable As Boolean
isTaxable = True
```

The following statement disables a TextField:

``` xojo
TextField1.Enabled = False
```

## Compatibility

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

<div class="seealso">

`False</api/language/false>`, `True</api/language/true>`, `VarType</api/language/vartype>` functions; `And</api/language/operators/bitwise_logical/and>`, `Not</api/language/operators/bitwise_logical/not>`, `Or</api/language/operators/bitwise_logical/or>`, `Xor</api/language/operators/bitwise_logical/xor>` operators; `Var</api/language/var>`, `Static</api/language/static>` statements; `VarType</api/language/vartype>` functions;

</div>
