I think I am having a senior moment and have forgotten how to do a VB trick I used to use all the time and cannot find any forum to help my memory.

I used to have value 0 to 15 and I thought I used "AND" as in 2 AND 2 it would return a 1 (or so I thought) because that bit is set. Same thing as 15 AND 2 = 1 because in 1111 the second bit is set. However I am not remembering it quite right because 2 AND 2 actually equals 2.

My program just tests bits 8,4,2 and 1 (four least significant bits) to see if they are set and then my conditions are based simply on a result of 1 or 0. Not 2 or anything higher.

Can someone please help me remember how I used to take a decimal number 0 - 15 and test it for a specific bit 8 (fourth bit),4(third bit),2(second bit) or 1(first bit) and just have it return a 1 or 0? I know I am forgetting something and I hope I explained it well what I am trying to do.

0 AND 0 = 0

0 AND 1 = 0

0 AND 2 = 0

0 AND 4 = 0

0 AND 8 = 0

1 AND 0 = 0

1 AND 1 = 1

1 AND 2 = 0

1 AND 4 = 0

1 AND 8 = 0

2 AND 0 = 0

2 AND 1 = 0

2 AND 2 = 1

2 AND 4 = 0

2 AND 8 = 0

3 AND 0 = 0

3 AND 1 = 1

3 AND 2 = 1

3 AND 4 = 0

3 AND 8 = 0

etc...

15 AND 0 = 0

15 AND 1 = 1

15 AND 2 = 1

15 AND 4 = 1

15 AND 8 = 1

Thank you.