Sample code for 30+ languages & platforms
Visual Basic 6.0

Compress Bytes

See more Compression Examples

Demonstrates how to compress binary data.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim fac As New CkFileAccess

Dim fileBytes() As Byte
fileBytes = fac.ReadEntireFile("qa_data/bmp/big.bmp")
If (fac.LastMethodSuccess <> 1) Then
    Debug.Print fac.LastErrorText
    Exit Sub
End If

Dim compress As New ChilkatCompression
compress.Algorithm = "deflate"

Dim compressedBytes() As Byte
compressedBytes = compress.CompressBytes(fileBytes)
If (compress.LastMethodSuccess <> 1) Then
    Debug.Print compress.LastErrorText
    Exit Sub
End If

success = fac.WriteEntireFile("qa_output/compressedBmp.dat",compressedBytes)
If (fac.LastMethodSuccess <> 1) Then
    Debug.Print fac.LastErrorText
    Exit Sub
End If