'********************************************************************
'*
'* Function LittleEndian
'*
'* Author: NetworkAdminKB.com
'* Created: 2004-02-21
'* Modified: 2007-01-05
'*
'* Purpose: Convert To and From the Little Endian format for HEX numbers.
'*
'* Input: strPair = A string of HEX pairs
'*
'* Output: Returns the string as converted To or From the Little Endian
'* format for HEX Numbers.
'*
'* Examples: LittleEndian("00000210") = "10020000"
'* LittleEndian("10020000") = "00000210"
'*
'********************************************************************
Function LittleEndian(ByVal strPair)
'Version: 1.1 2007-01-05
Dim lenStr, tempStr1, tempStr2
lenStr = Len(strPair)
If lenStr Mod 2 <> 0 Then
Wscript.Echo "LittleEndian: ", _
"The HEX string must be an even number of characters"
Wscript.Echo " ", _
"The current value has an odd number of characters: " & strPair
LittleEndian = Empty
Exit Function
End If 'lenStr Mod 2 <> 0
tempStr1 = strPair
tempStr2 = ""
If lenStr > 2 Then
Do While Len(tempStr1) >= 2
tempStr2 = Left(tempStr1, 2) + tempStr2
tempStr1 = Right(tempStr1, Len(tempStr1) - 2)
Loop
Else
tempStr2 = tempStr2 + strPair
End If 'lenStr > 2
LittleEndian = tempStr2
End Function 'LittleEndian
Article ID: 404, Created On: 9/25/2011, Modified: 9/25/2011