|
-
Aug 29th, 2000, 04:06 AM
#1
Thread Starter
Hyperactive Member
Hi,
My VB 6 help isn't working so I couldn't find an answer - says I have to install MSDN library or something. I also tried a search on this board but couldn't find a simple answer.
So what's a boolean? It's something I've been cutting and pasting throughout my project, but I'd like to know how it works and what it is.
Thanks for any help!
-
Aug 29th, 2000, 04:18 AM
#2
transcendental analytic
A boolean variable can only have two values:
0 - False
-1 - True
when you convert to boolean with cbool or assinging a nonbolean value to a boolean value everything except 0 is True. To declare a boolean variable:
Code:
Dim a as boolean
private a as boolean
public a as boolean
also a boolean variables takes up 2 bytes
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 29th, 2000, 05:28 AM
#3
Fanatic Member
be a bit careful, VB is a little erratic, sometimes -1 is false, as is the case where -1 is returned from some search funtions when nothing is found (like rtfbox.find() ) although not the instr() which is fine.
Where possible refer to just True & False
Binary is:
1 = true
0 = False
but the boolean data type is 16 bit which makes things a little odd.
I find that it's best benefit is that it makes code more readable saying that something is true or false rather than have a value.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Aug 29th, 2000, 09:19 AM
#4
Hyperactive Member
If a function returns -1 to indicate nothing was found, it's declared as integer or long, not as boolean.
A boolean is within VB always 0 and -1, although it accepts 0 as false and anything else as true. (and luckily, every other programming language I know 0 = false and 1 = true...).
But I agree, if you use the find function in a If Then statement, you need to be careful indeed (but then still, it's not a boolean that is returned and therefor it's recommended to check for " = -1" or " > -1".....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|