Boolean

 <  Day Day Up  >  

The Boolean data type can store the two Boolean values "true" and "false." The Boolean data type is primarily used in conditional statements such as If or While , since the comparison operators (such as < or = ) result in a Boolean value. For example, in the following function, the Negative local variable determines what is printed.

Table 3-1. Fundamental Types

Type

Description

Boolean

A Boolean (true/false) value

Byte

A 1-byte unsigned integer

Short

A 2-byte signed integer

Integer

A 4-byte signed integer

Long

An 8-byte signed integer

Decimal

A 16-byte scaled decimal number

Single

A 4-byte single precision floating-point number

Double

An 8-byte double precision floating-point number

Date

A time/date value

Char

A single Unicode character

String

A string of Unicode characters

 Dim a As Integer Dim Negative As Boolean a = 10 - 20 Negative = a < 0 If Negative Then   Console.WriteLine("Less than zero.") Else   Console.WriteLine("Greater than or equal to zero.") End If 

The Boolean values "true" and "false" are represented by the literals True and False , respectively. The default value of Boolean is the literal False .

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net