sftp/Module1.bas

' Technical support: support@smartftp.com

Attribute VB_Name = "Module1"
Option Explicit

Public objSSH As sfFTPLib.SSHConnection
Public objSFTP As sfFTPLib.SFTPConnection
Public objGlobal As sfFTPLib.Global

' With events
'Dim WithEvents objSFTP As SFTPConnection

Sub SFTPTest()
	Set objSFTP = objSSH.CreateSFTPConnection()
	objSFTP.Connect()
	Dim strHome
	strHome = objSFTP.RealPath(".")
  MsgBox ("RealPath() successful.")
  ' Read Directory
  Dim objItems As sfFTPLib.FTPItems
  Set objItems = objSFTP.ReadDirectory(strHome)
  Dim objItem As sfFTPLib.FTPItem
  Dim strList
  For Each objItem In objItems
  	strList = strList & "Type=" & objItem.Type & "; Name=" & objItem.Name & "; Size=" & objItem.SizeLo & Chr(13) & Chr(10)
  Next
  	MsgBox (strList)
 
 	' Download File
  Dim nRestartLo : nRestartLo = 0
 	Dim nRestartHi : nRestartHi = 0

  Dim strMsg
  objSFTP.DownloadFile("/path/file", "myfile", nRestartLo, nRestartHi)
  strMsg = "DownloadFile() successful." & Chr(13) & Chr(10)
  strMsg = strMsg & "LastTransferBytes = " & objSFTP.LastTransferBytesLo & " B" & Chr(13) & Chr(10)
  strMsg = strMsg & "LastTransferTime = " & objSFTP.LastTransferTime & " s" & Chr(13) & Chr(10)
  strMsg = strMsg & "LastTransferSpeed = " & objSFTP.LastTransferSpeed & " B/s"
  MsgBox (strMsg)
End Sub

Sub Main()
    ' VB6 binding howto
    ' http://kandkconsulting.tripod.com/VB/Tutorials/vb_binding_tutorial.htm

    'Early Binding "Dual Interface"
    'Note: Force the compiler to use the dual interface if available
    Set objGlobal = CreateObject("sfFTPLib.Global")

		' TODO: Insert serial
		'objGlobal.LoadLicense("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

    'Early Binding "Dual Interface"
    'Note: Force the compiler to use the dual interface if available
    Set objSSH = CreateObject("sfFTPLib.SSHConnection")
    
    'Early Binding "Mid Level"
    'Note: The compiler may use the dual interface
    'Set objSSH = New sfFTPLib.SSHConnection
    
    objSSH.Host = "yourhost"
    objSSH.Port = 22
    objSSH.Username = "anonymous"
    objSSH.Password = "test@test.com"
    objSSH.LogFile.File = "VB6Demo.log"
    
    objSSH.Connect()
    MsgBox ("Connected.")
		SFTPTest()		
		objSSH.Disconnect()
End Sub