|
-
Dec 23rd, 2014, 04:07 AM
#6
Re: Confused about using NOT and AND operators
Are you talking about "Not CBool(isqTo And &H88)" ?
Both numbers are in parentheses so will be operated on first.
isqTo is a number, and &H88 is a number, so those will be Binary Anded together, and the result converted to a boolean (True or False) by the CBool function, and that boolean logically negated to (False or True) by the Not operator.
The two examples given,
(3 And &H88) result is 0, so 0 is converted to False (0), then the Not returns True (-1).
(15 And &H88) the result is 8. so 8 is converted to True (-1) and the Not returns False (0).
Without the CBool
(15 And &H88) gives 8, and the Not complements (ones) the bits, so becomes -9, and any non-zero value will be evaluated as "True" in an If statement, so both (3 and &H88) and (15 and &H88) would be evaluated as True by the If without the CBool.
If you're talking the original OP example,
If Not isqTo And &H88 Then
Then, yes the Not inverts isqTo first, and Ands it with &H88, giving a different set of numbers, but still a non-zero result in a lot of cases that will be evaluated as True by the If, such is the case of both examples of 3 and 15.
Of course, 3 is being inverted to -4, and Anded with &H88 resulting in 136, which is evaluated as True because it is non-zero, not because it was 0 (false) and logically inverted to True, so the assumption that 3 and &H88 was "working" wasn't really true.
Last edited by passel; Dec 23rd, 2014 at 10:27 AM.
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
|