Code
Private Function ZipPK_MM(Val() As Byte, Password As String, ZipControl As Zip, ByRef Status() As Variant) As Byte()
'Purpose
'   Used to compress a value and return the result as a byte array.
'Parameters
'   Val (Byte()) = The value we want to compress.
'   Password (String) = A password used to decrypt the value.
'       A password is not used to decode the value if it is zero-length.
'   ZipControl (Zip) = A reference to the Dart Zip control we're going to use for compression.
'   Status (Variant()) = A standard rtStatus array. This is used to return status information.
'       Returned status values are taken directly from the Dart Zip control and DartStream objects.
'       Status conditions are reported in the first two elements only. Any additional elements are unchanged.
'       This must enter with two or more elements (zero-based) or function may crash.
'Return (Byte())
'   Returns the specified value compressed.
'   If an error occurs, returns an empty Byte array.
'Exit Conditions
'   The FileStore object of the Zip control has been altered.
'Dependencies
'   The Dart "Zip" control must be referenced in the hosting application.
'   The following functions must be directly callable:
'       IsEmptyArray
'Version History
'   1.0 7/4/2004 Tested by Russ Tanner
'---

'Set status trap
On Error GoTo ZipPK_MM_Error:

'Initiate variables
Dim StreamIn As New DartStream
Dim StreamOut As New DartStream
Dim EmptyByteArray() As Byte

'Clear the status condition
Status(0) = CLng(0)
Status(1) = ""

'Remove all previous files from the FileStore
ZipControl.FileStore.Clear

'Add the specified value (Val) to a DartStream
'WORKAROUND: DARTSOCK.DLL generates a critical "Access Violation" when
'an empty byte array is passed to the Dart Zip control.
'If Val enters with zero elements, pass a zero-length string to the input stream
If isEmptyArray(Val) Then
    StreamIn.Write ""
Else
    StreamIn.Write Val
End If

'Zip the value. Use a password only if it is specified.
If Password = "" Then
    ZipControl.FileStore.Add StreamIn, False, False, "", zipNoEncryption
Else
    ZipControl.FileStore.Add StreamIn, False, False, Password, zipStandard
End If

'Zip the value to a compressed DartStream
ZipControl.FileStore.Zip StreamOut

'Remove all previous files from the FileStore
ZipControl.FileStore.Clear

'Return the result
StreamOut.Position = 0 'Must rewind the stream to read from it
ZipPK_MM = StreamOut.ReadBytes 'Return the compressed value

Exit Function

'Error Trap
ZipPK_MM_Error:

'An error occured, return an empty byte array
ZipPK_MM = EmptyByteArray

'Remove all previous files from the FileStore
ZipControl.FileStore.Clear

'Return the error information
Status(0) = Err.Number
Status(1) = Err.Description

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)