Code
Public Function AsLong_ByteArray(ByteArray() As Byte) As Long
'Purpose
'   Used to convert a byte array to a long.
'Parameters
'   ByteArray (Byte()) = The byte array to convert.
'Return (Long)
'   Returns the specified byte array as a long.
'   If the specified byte array has no elements, function returns zero.
'Dependencies
'   ElementCount
'Entry Conditons
'   The specified byte array must be convertable to a long by the VB CLng() function or this function will crash.
'Notes
'   This is an example of an "unpacked" long with a value of 12:
'       (0) 0   (1) 0   (2) 1   (3) 2
'       This "unpacked" format stores the actual decimal value of each decimal "place" in each element.
'       It *does not* store the ASCII value of characters which represent the value.
'       Note that the LSB is the one with the highest index.
'Version History
'   1.0 5/28/2004 Tested by Russ Tanner
'---

'Initiate variables
Dim C As Long 'Loop counter
Dim eCount As Long 'The number of elements in the parsed byte array
Dim X As String 'String buffer for returned long (before being converted to a long)

'Get the element count of the parsed byte array
eCount = elementCount(ByteArray)

'Trap: The specified byte array is empty, function always return zero
If eCount = 0 Then
    asLong_ByteArray = 0
    Exit Function
End If

'Main loop: Build a string from the (unpacked) elements of the byte array
For C = 0 To eCount - 1
    X = X & Trim(CStr(ByteArray(C)))
Next C

'Convert the string into a long and return the result
asLong_ByteArray = CLng(X)

End Function


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)