Skip to main content
NetworkAdminKB Logo

VBScript Library

Go Search
NetworkAdminKB.com
Knowledge Base
VBScript Library
Utilities
  
NetworkAdminKB.com > VBScript Library > Knowledge Base > Components > Arrays > Octet2HexStr  

Octet2HexStr

Article Content

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

'*

'* 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

Keywords
Array Conversion 
Related Articles
 
Last modified at 1/11/2009 1:39 PM  by TEMPLATE\kbadmin 
 
 NetworkAdminKB.com
 Copyright © 2008 NetworkAdminKB.com, All rights reserved. Terms of Use | Contact US