I was working on a program that used an integer sized bitfield where each bit represented something different. One of the possible states for the bitfield I set as &HFFFFFFFF, just so that all bits were set.

Later, I decided that I had to differentiate between 'No bits set' and 'Unused'. Naturally, no bits set is 0, but I needed another number for unused. I chose -1.....oops, that's &HFFFFFFFF.

Bit fields can be used as numbers, or bits, but if you use them as both, keep in mind that negative numbers will cause you problems. When I saw what I had done, I laughed. There is a maximum size for an unsigned int, and a maximum size for a signed int (which is half as big as the maximum for an unsigned int). In general, VB.NET uses signed ints only, but you can make it act like an unsigned int in some cases....you just can't have it both ways!