Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Create WinZip Compatible Password-Protected Zip

Download Chilkat 32-bit Zip ActiveX (.msi) (includes objects for .zip, .gz, .bz2, and .Z)

Download All 32-bit Chilkat ActiveX Components (.zip)

Download All 64-bit Chilkat ActiveX Components (.zip)

Visual Basic sample code to create a WinZip compatible password-protected Zip.

Dim ZipFile As ChilkatZip2

Private Sub Command1_Click()
    
    ' Get the zip file name
    CommonDialog1.ShowOpen
    CommonDialog1.CancelError = True
    SourceFile.Text = CommonDialog1.FileName
     
End Sub

Private Sub Command2_Click()
    
    ' Create a ChilkatZip object
    Set ZipFile = New ChilkatZip2
    ZipFile.UnlockComponent UnlockCode.Text
    ZipFile.NewZip OutputZip.Text
    
    ' To create a WinZip-compatible password-protected Zip, simply
    ' set the PasswordProtect property to 1, and set a password.
    ' To unzip, WinZip will prompt for this password.
    ZipFile.PasswordProtect = 1
    ZipFile.SetPassword "secret"
    
    ' Add the disk file to the Zip object
    ZipFile.AppendFiles SourceFile.Text, 0
    
    ' See if anything was added.
    If (ZipFile.NumEntries = 0) Then
        ZipStatus.Caption = "Error, no files added to the Zip archive."
        Set ZipFile = Nothing
        Exit Sub
    End If
    
    ' Compress and write to disk.
    success = ZipFile.WriteZip()
    If (success = 0) Then
        MsgBox ZipFile.LastErrorText
        Exit Sub
    End If

    ' How much compression occured?
    Dim e As ChilkatZipEntry2
    Set e = ZipFile.GetEntryByIndex(0)
    If (Not (e Is Nothing)) Then
        origSize = e.UncompressedLength
        compressedSize = e.CompressedLength
        ZipStatus.Caption = "Success." + vbCrLf + Str(origSize) + " bytes compressed to " + Str(compressedSize) + " bytes"
        Set e = Nothing
    End If
    
    ZipFile.CloseZip
    
    Set ZipFile = Nothing
    
End Sub

Private Sub Form_Load()
    OutputZip.Text = CurDir$ + "\outputFile.zip"
    
End Sub

    

 

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