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

 

 

 

 

 

 

 

FTP Upload with Heartbeat Events, Abort, and Transfer Rate Monitoring

Download 32-bit Chilkat FTP2 ActiveX (.msi)

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

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

Visual Basic 6.0 example program demonstrating FTP upload heartbeat events, abort capability, and real-time upload transfer rate monitoring.

Dim WithEvents ftp As ChilkatFtp2
Dim AbortButtonPressed As Boolean

Private Sub AbortButton_Click()
    AbortButtonPressed = True
End Sub

' Upload a file with progress monitoring.
Private Sub Command1_Click()

    AbortButtonPressed = False
    
    Set ftp = New ChilkatFtp2
    
    success = ftp.UnlockComponent("anything for 30-day trial")
    If (success = 0) Then
        MsgBox "Failed to unlock component"
        Exit Sub
    End If
    
    ' Set our heartbeat interval to .1 seconds
    ' This causes ftp_AbortCheck to be called approximately every .1 seconds.
    ftp.HeartbeatMs = 100

    ' Set the FTP hostname, login, and password.
    ftp.HostName = "ftp.yourftpserver.com"
    ftp.Username = "***"
    ftp.Password = "***"

    ' Connect and login to the FTP server.  Heartbeat events fire during the
    ' the connection establishment, authenticaion, and during all other communications
    ' with the FTP server.
    success = ftp.Connect()
    If (success = 0) Then
        MsgBox ftp.LastErrorText
        Exit Sub
    End If
       
    ' Upload a file to the FTP server.
    localFile = "hamlet.xml"
    remoteFile = "hamlet.xml"
    success = ftp.PutFile(localFile, remoteFile)
    If (success = 0) Then
        MsgBox ftp.LastErrorText
        Exit Sub
    End If
    
    ftp.Disconnect
    
    MsgBox "Finished!"

End Sub

' Called periodically according to the HeartbeatMs property.
Private Sub ftp_AbortCheck(abort As Long)

    ' This example aborts the transfer if the "abort button"
    ' in the user interface is pressed.
    If AbortButtonPressed Then
        abort = 1
    End If
    
    ' Update a progress bar so we can visually see the hearbeat.
    If ProgressBar2.Value = 100 Then
        ProgressBar2.Value = 0
    Else
        ProgressBar2.Value = ProgressBar2.Value + 10
    End If
    
    ' Display the real-time transfer rate as the upload progresses.
    Label1.Caption = "Bytes/Second: " & Str(ftp.UploadRate)
    Label1.Refresh
    
    ' Process user-interface events while waiting for the FTP transfer
    ' to complete.
    DoEvents
    
End Sub

' Provides percentage-completion progress monitoring.
Private Sub ftp_PutProgress(ByVal pctDone As Long)
    ProgressBar1.Value = pctDone
End Sub


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