![]() |
Different uses of AND function
Hi!
I have a code from an unknow author which I try to understand, but I can't! Can you help me guys? The code is: Function bitcheck(ival As Integer, ibit As Integer) bitcheck = 0 If (ival And 2 ^ ibit) 0 Then bitcheck = 1 End Function But when I change the If statement for this: If ival 0 and 2 ^ ibit 0 then bitcheck = 1 the function does not give the same answer. Why?? Thanks! |
Different uses of AND function
On 25 Ago, 22:13, Mathieu936 wrote:
Hi! I have a code from an unknow author which I try to understand, but I can't! Can you help me guys? The code is: Function bitcheck(ival As Integer, ibit As Integer) * *bitcheck = 0 * *If (ival And 2 ^ ibit) 0 Then bitcheck = 1 End Function in this code AND is used as binary operator: debug.print 3 AND 2 ' - 11 and 10 - 10 = 2 debug.print 2 AND 2 ' - 10 and 10 - 10 = 2 debug.print 1 AND 2 ' - 01 and 10 - 00 = 0 debug.print 3 AND 1 ' - 11 and 01 - 01 = 1 * *If ival 0 and 2 ^ ibit 0 then bitcheck = 1 in your code AND is used as logic operator: debug.print true and true - true debig.print false and true - false Bye! Scossa |
Different uses of AND function
Hey Thanks Scossa!
I would never found it by myself! Mathieu |
All times are GMT +1. The time now is 03:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com