# GBIC: Boolean logic

The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.

Boolean refers to logical relationships - True or False, and is namedafter mathematician George Boole.

VB supports the following Boolean opertors

• Or
• And
• Not
• Xor

The following operators are also supported but see very little use by VB programmers

• Eqv
• Imp
• Is

To create a Boolean variable, use this:

`Dim X As Boolean`

Mathematical values used in Boolean expresssion are converted to Boolean values as follows:

• 0 becomes False
• all other values become True .

Boolean values used in mathematical expressions are converted to mathematical values as follows:

• False becomes 0 i.e. False * 2 = 0
• True becomes - 1 i.e. True * 5 = - 5

results of applying Val to Boolean

• Val( True ) = 0
• Val( False ) = 0
• Abs( True ) = 1
• Abs( False ) = 0
• CInt ( True ) = - 1
• CInt ( False ) = 0
• Print True ---> True
• Print False ---> False

`If A Then     '0 value is treated as False    'non-zero value is treated as TrueEnd If`

Posted: 2021-02-11
By: ArchiveBot
Viewed: 119 times

Categories

Visual Basic 6

Attachments

No attachments for this post