'********************************************************************

'*

'* Sub Octet2HexStr

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2006-05-07

'* Modified: 2007-01-06

'*

'* Purpose: Convert OctetString (byte array) to Hex string.  The bytes

'*            can also be delimited by '\' for an ADO filter.

'*

'* Input:   aryOfBytes        A byte array (VarType = 8209)

'*          blnADO         A boolean indicating output format.

'*                           True  = ADO Filter format where Hex Values

'*                                    are delimited by '\' for an ADO filter.

'*                           False = ADS_SID_HEXSTRING format, where only the

'*                                    HexString is returned.

'*

'* Return:  A string of Hex Values, the string format is based on the

‘*            blnADO variable.

'*

'* Changes:

'* 2007-01-06: Added ByVal to the parameters

'********************************************************************

Function Octet2HexStr(ByVal aryOfBytes, ByVal blnADO)

  'Version: 1.1 2007-01-06

  Dim k

  Octet2HexStr = ""

  For k = 1 To LenB(aryOfBytes)

    If blnADO Then

      Octet2HexStr = Octet2HexStr & "\"

    End If 'blnADO

    Octet2HexStr = Octet2HexStr & Right("0" & Hex(Ascb(Midb(aryOfBytes, k, 1))), 2)

  Next 'k = 1 To LenB(aryOfBytes)

End Function 'Octet2HexStr

Article ID: 409, Created On: 9/25/2011, Modified: 9/25/2011