Thread
:
Can I use AND like this
View Single Post
#
6
Posted to microsoft.public.excel.programming
Tushar Mehta
external usenet poster
Posts: 1,071
Can I use AND like this
How have you declard lchecks?
It works just fine for me for types byte, long, and variant.
If lchecks is a boolean, VBA treats the assignment as setting it to
true, i.e., -1 or all bits on or &HFFFF. The result is that all tests
(lchecks and {whatever}) will be true.
So, in no case can I duplicate your problem of getting zero.
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
In article ,
says...
Actually it's not working like I thought
lchecks = lchecks + 2
?lchecks and 2
0
"Tom Ogilvy" wrote in message
...
To set the bit, add the constant to lChecks
lChecks = lChecks + const_Sub
From the immediate window:
lchecks = lchecks + 4 + 8
? lchecks and 2
0
? lchecks and 4
4
? lchecks and 8
8
? lchecks and 16
0
? lchecks and 1
0
--
Regards,
Tom Ogilvy
"D" wrote in message
...
like a bitwise and,
I've definded constants const_add 1, const_sub 2, const_div 4 ,, 8 , 10 ,
20
etc
if CheckBox_Add.Value = True Then
lChecks = lChecks And const_Add
End If
If CheckBox_Sub.Value = True Then
lChecks = lChecks And const_Sub
End If
I'd like pass lChecks to a function and have that function do something
like
if lChecks and const_add = true then
.....
It all looks ok but my lines like lChecks = lChecks And const_Add don't
set
lChecks to anything
Thanks
Reply With Quote
Tushar Mehta
View Public Profile
Find all posts by Tushar Mehta