|
Home
Languages
VB6
JavaScript
Perl
HTML
SQL
Java
DOS
Forums
Web Site
Software
gbCodeLib
Personal
Webcam
Biography
Contact Me
|
GBIC >>
Source Code >>
Visual Basic >> Snippet
|
07 Boolean logic
'Boolean refers to logical relationships - True or False, and is named
'after 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 True
End If
|
|
|
|