VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
PFX
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Byte Array
VB.NET FTPS
System.IO

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

PPMD Streaming String Compression

Demonstrates streaming string compression using PPMD. Data may be compressed in chunks by initially calling one of the BeginCompress* methods, followed by 0 or more calls to a MoreCompress* method, and terminating with a call to an EndCompress* method.

Likewise, data may be decompressed by calling a BeginDecompress* method, followed by 0 or more MoreDecompress* calls, and ending with an EndDecompress* method call.

This example demonstrates string-to-string compression and decompression in chunks.

The functionality in this example is available in pre-release only:
To use, unzip and add a reference to the enclosed DLL in your .NET project.

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

Dim compress As New Chilkat.Compression()

'  Any string argument automatically begins a 30-day trial.
Dim success As Boolean
success = compress.UnlockComponent("30-day trial")
If (success <> true) Then
    MsgBox("Compression component unlock failed")
    Exit Sub
End If


compress.Algorithm = "ppmd"
compress.Charset = "ansi"
compress.EncodingMode = "base64"

Dim strData As String
Dim i As Long

Dim strCompressed As String

'  Create a long string to compress.
strData = "abcdefg1122334455667788"
strData = strData & vbCrLf

'  Note: BeginCompressStringENC may return a zero-length
'  string.  This is normal if the input is buffered and no
'  compressed data is yet available.
'  However, a null reference indicates an error -- which is
'  generally only possible if the component was never unlocked.
strCompressed = compress.BeginCompressStringENC(strData)
If (strCompressed = vbNullString ) Then
    MsgBox(compress.LastErrorText)
    Exit Sub
End If


'  Compress 100 more chunks of data.  Each call to
'  MoreCompressStringENC may or may not produce additional
'  compressed output.
For i = 0 To 99
    strData = "abcdefg1122334455667788"
    strData = strData & vbCrLf

    strCompressed = strCompressed & compress.MoreCompressStringENC(strData)
Next

'  Finalize the compression with a single call to EndCompressStringENC:
strCompressed = strCompressed & compress.EndCompressStringENC()


'  Display the compressed string.
'  The result will be:
'  ec8YZ5vk9za18d0plwuV7R65em9OZge9gJXht/QAAAAAAAAAABNOZQAAKw==

TextBox1.Text = TextBox1.Text & strCompressed & vbCrLf

'  Decompress back to the original in a single call.
Dim strOriginal As String
strOriginal = compress.DecompressStringENC(strCompressed)

'  Display the uncompressed original:
TextBox1.Text = TextBox1.Text & "--- Original ---" & vbCrLf
TextBox1.Text = TextBox1.Text & strOriginal & vbCrLf


'  Decompress in multiple calls.  It doesn't matter how the
'  compressed data is split -- it could be fed to the decompressor
'  one char at a time if desired.
Dim chunk1 As String
chunk1 = "ec8YZ5vk9za1"
Dim chunk2 As String
chunk2 = "8d0p"
Dim chunk3 As String
chunk3 = "lwuV7R65em9OZge9gJXht/QAAAA"
Dim chunk4 As String
chunk4 = "AAAAAABNOZQAAKw=="

strOriginal = ""
strOriginal = compress.BeginDecompressStringENC(chunk1)
strOriginal = strOriginal & compress.MoreDecompressStringENC(chunk2)
strOriginal = strOriginal & compress.MoreDecompressStringENC(chunk3)
strOriginal = strOriginal & compress.MoreDecompressStringENC(chunk4)
strOriginal = strOriginal & compress.EndDecompressStringENC()

'  Display the uncompressed original after decompressing in chunks:
TextBox1.Text = TextBox1.Text & "--- Original after Decompressing from Chunks ---" & vbCrLf
TextBox1.Text = TextBox1.Text & strOriginal & vbCrLf
 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser