Export (0) Print
Expand All
23 out of 65 rated this helpful - Rate this topic

Boolean Data Type (Visual Basic) 

Holds values that can be only True or False. The keywords True and False correspond to the two states of Boolean variables.

Use the Boolean data type to contain two-state values such as true/false, yes/no, or on/off.

The default value of Boolean is False.

Type Conversions

When Visual Basic converts numeric data type values to Boolean, 0 becomes False and all other values become True. When Visual Basic converts Boolean values to numeric types, False becomes 0 and True becomes -1.

When you convert between Boolean values and numeric data types, keep in mind that the .NET Framework conversion methods do not always produce the same results as the Visual Basic conversion keywords. This is because the Visual Basic conversion retains behavior compatible with previous versions. For more information, see Troubleshooting Data Types.

Programming Tips

  • Negative Numbers. Boolean is not a numeric type and cannot represent a negative value. In any case, you should not use Boolean to hold numeric values.

  • Type Characters. Boolean has no literal type character or identifier type character.

  • Framework Type. The corresponding type in the .NET Framework is the System.Boolean structure.

In the following example, runningVB is a Boolean variable, which stores a simple yes/no setting.

Dim runningVB As Boolean
' Check to see if program is running on Visual Basic engine.
If scriptEngine = "VB" Then
    runningVB = True
End If
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.