Function Bitwise Class

BinaryStringToString

"Binary String To String" or "String From Binary String" Uses each character from one string to form one bit of another string. Turns a string such as "0000001100001100" into something Chr$(3) + Chr$(12). Order of incoming BITS determined by vFromLSBFirst argument. Order of outgoing BYTES determined by vToLSBFirst. The inverse of this function is BinaryStringFmString .

Signature (Visual Basic / VBA)

Public Function BinaryStringToString( _
      ByVal vValue As Variant _
    , ByVal vToLSBFirst As Variant _
    , Optional ByVal vFmLSBFirst As Variant _
    ) As Variant

Code Example

    BinaryStringToString("0000001100001100", False, False) = Chr$(3) + Chr$(12)
    BinaryStringToString("0000110000000011", True,  False) = Chr$(3) + Chr$(12)
    BinaryStringToString("0011000011000000", False, True) = Chr$(3) + Chr$(12)
    BinaryStringToString("1100000000110000", True,  True) = Chr$(3) + Chr$(12)

Parameters

Parameter Description
vValue The string in which each character represents one of the bits within the result string. Function returns Null if vValue is Null or cannot be fixed up to a String.
vToLSBFirst True if the result string should represent the bits with the least-significant-byte first, and False if it should represent the bits with the most-significant-byte first. vToLSBFirst defaults to False if it is Null or cannot be fixed up to a number.
vFmLSBFirst True if the bits in string vValue are organized with the least-significant-bit first, and False if they are organized with the most-significant-bit first. vFmLSBFirst defaults to False if it is missing or Null or cannot be fixed up to a number.

Notes & Version History

Details Note that arguments to this function and BinaryStringToString are organized so that the functions are the inverse of each other when the second and third arguments are the same.