' Toggle a bit in a value'' NOTE: requires Power2()Function BitToggle(ByVal value As Long, ByVal bit As Long) As Long ' simply XOR with the negation of the bit mask ' Range checking is performed in Power2() BitToggle = (value Xor Power2(bit))End Function