' The byte array which will contain the data to save or transfer:
Dim TempByteArray() As Byte
' We'll put some text to compress here:
Dim OriginalData As Variant
' Xceed Compression will place the compressed data here:
Dim CompressedData As Variant
' To uncompress the data we'll put it in this variable:
Dim ToUncompress As Variant
' Xceed Compression will place the uncompressed data here:
Dim UncompressedData As Variant
' The result codes will be placed in this variable
Dim ResultCode As xcdCompressionError
OriginalData = "Text or data to compress"
Call XceedCompression1.License( "your license key" )
ResultCode = XceedCompression1.Compress(OriginalData, CompressedData, True)
' Make sure it worked successfully, display message
If ResultCode <> xerSuccess Then
MsgBox "Compression unsuccessful. Error # " & Str(ResultCode) & " occurred. " & _
"Description: " & XceedCompression1.GetErrorDescription(ResultCode)
Else
MsgBox "Compression successful."
End If
' Now the CompressedData variable is a Byte Array Variant, but it still cannot
' be assigned properly to other properties or used by the Get and Put method until
' we convert it to a real byte array as follows:
ReDim TempByteArray(1 To UBound(CompressedData)) As Byte
TempByteArray = CompressedData
' Ok, now you can do whatever you want with the compressed data located in the
' " TempByteArray" byte array variable (not a Variant!)
' [Save, process or transfer your data here!]
' Ok, now its time to decompress your saved data, so place it in the TempByteArray byte array variable.
' [Load your saved or transferred compressed data here!]
' Lets convert it to a Variant Byte Array before uncompressing it
ToUncompress = TempByteArray
' Now let's uncompress the data
ResultCode = XceedCompression1.Uncompress(ToUncompress, UncompressedData, True)
' UncompressedData variable should now contain same data as the OriginalData variable
' Check to see if it worked properly, display message
If ResultCode <> xerSuccess Then
MsgBox "Decompression unsuccessful. Error # " & Str(ResultCode) & " occurred. " & _
"Description: " & XceedCompression1.GetErrorDescription(ResultCode)
Else
MsgBox "Decompression successful."
End If