DataType

Boolean


Description

Boolean is an intrinsic data type. A Boolean can only take on the values of True or False. The default value is False.

Methods

Name

Parameters

Returns

Shared

FromString

value As String

Boolean

ToString

Boolean

Method descriptions


Boolean.FromString

FromString(value As String) As Boolean

Returns the value passed as a Boolean.

This method is shared.

If the value is "True", then True is returned, otherwise the False is returned.

This example sets a Value property of a CheckBox to True by passing the String True to the FromString function. This can be useful for setting Boolean values of classes such as CheckBox from Strings coming from files or databases.

CheckBox1.Value = Boolean.FromString("True")

Boolean.ToString

ToString As Boolean

Returns the value as a string.

If the value is True, the String "True" is returned, otherwise the String "False" is returned.

This example displays "True" or "False" in the MessageBox depending on whether the property is set to True or False.

MessageBox(Window1.HasCloseButton.ToString)

Notes

A Boolean is a variable that can have one of two values. In Xojo, the values are True or False. You can think of True as the equivalent of Yes or On, whereas False is equivalent to No or Off.

Boolean values are False by default but can be set to True using the True keyword and back to False using the False keyword.

The VarType function returns 11 when passed a Boolean variable.

Sample code

Declares a Boolean variable and sets its value to True:

Var isTaxable As Boolean
isTaxable = True

The following statement disables a TextField:

TextField1.Enabled = False

Compatibility

All project types on all supported operating systems.

See also

False, True, VarType functions; And, Not, Or, Xor operators; Var, Static statements; VarType functions;