How to: Hold True and False Values in a Variable

A variable holds true and false values if you declare it to be of data type Boolean.

A variable of the Boolean Data Type (Visual Basic) can hold two-state logical values such as true/false, on/off, and yes/no.

If you need to hold numeric values, use a numeric data type such as Integer or Double instead of Boolean. You should never use Boolean values as numbers, and you should never rely on equivalent numeric values for them. For more information, see Troubleshooting Data Types.

To hold true and false values in a variable

  1. Declare the variable with a Dim Statement (Visual Basic).

  2. Follow the variable name with an As clause.

  3. Follow the As keyword with the Boolean keyword.

See Also

Tasks

Troubleshooting Data Types

Concepts

Data Types in Visual Basic

Type Characters

Reference

Data Type Summary (Visual Basic)

Single Data Type (Visual Basic)

Boolean Data Type (Visual Basic)

Integer Data Type (Visual Basic)

Double Data Type (Visual Basic)

Other Resources

Elementary Data Types