Function Bitwise Class

GetBit

Get a bit from any type of value. Return True if the specified bit is on, or False if it is off. Bits range from 1 (one is the least-significant-bit) to the number of bits in the value.

Signature (Visual Basic / VBA)

Public Function GetBit( _
      ByVal vValue As Variant _
    , ByVal vBit As Variant _
    ) As Variant

Code Example

    GetBit(2, 2) = True
    GetBit(2, 1) = False
    GetBit(Chr$(2) + Chr$(0), 10) = True
    GetBit(Chr$(2) + Chr$(0), 2) = False

Parameters

Parameter Description
vValue Value from which one of the bits of its in-memory representation is to be returned. Function returns Null if vValue is Null.
vBit The number of the bit whose value within variable vValue is to be returned. Function returns Null if vBit is Null of cannot be fixed up to a number. Function returns Null if vBit is <= 0 (less than or equal to zero). Function returns Null if vBit is greater than the number of bits within the value vValue.