Boolean Data Type - Visual Basic | Microsoft Learn
Maybe your like
Share via
Facebook x.com LinkedIn Email PrintNote
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Boolean Data Type (Visual Basic) Feedback Summarize this article for meIn this article
Holds values that can be only True or False. The keywords True and False correspond to the two states of Boolean variables.
Remarks
Use the Boolean Data Type (Visual Basic) to contain two-state values such as true/false, yes/no, or on/off.
The default value of Boolean is False.
Boolean values are not stored as numbers, and the stored values are not intended to be equivalent to numbers. You should never write code that relies on equivalent numeric values for True and False. Whenever possible, you should restrict usage of Boolean variables to the logical values for which they are designed.
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 "Boolean Type Does Not Convert to Numeric Type Accurately" in 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.
Example
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 IfSee also
- System.Boolean
- Data Types
- Type Conversion Functions
- Conversion Summary
- Efficient Use of Data Types
- Troubleshooting Data Types
- CType Operator
.NET
Open a documentation issue Provide product feedbackFeedback
Was this page helpful?
Yes No NoNeed help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Ask Learn Ask Learn Suggest a fix?Additional resources
- Last updated on 2025-08-30
In this article
Was this page helpful?
Yes No NoNeed help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Ask Learn Ask Learn Suggest a fix?Tag » What Is A Boolean Value
-
Boolean Values - IBM
-
What Is A Boolean Data Type, And What Are Some Uses? - SitePoint
-
Boolean Values
-
Boolean Variable - An Overview | ScienceDirect Topics
-
What Is A Boolean? - Computer Hope
-
What Is A Boolean? - Lifewire
-
True/False / Examples /
-
Boolean - JavaScript - MDN Web Docs
-
Boolean Or Truth Values - Analytica Wiki
-
Boolean Data Type – Programming Fundamentals - Rebus Press
-
7.1. Boolean Values And Boolean Expressions - Runestone Academy
-
Boolean Data Type In Python - GeeksforGeeks
-
Learn Booleans In JavaScript