Hi,
I have this code to upload files to a server.
It works fine.
Now I need to add a progress bar to let the users know that the app is still working and isn't just dead. Something that will start at the beginning of this procedure and end at his end.
Thanks in advance.
I have this code to upload files to a server.
Code:
Option Compare Database
Option Explicit
Option Private Module
'-------------------
'API Declaration
'-------------------
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, _
ByVal nServerPort As Integer, _
ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
"FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _
ByVal lpszDirectory As String) As Boolean
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hConnect As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Long, _
ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _
ByRef dwContext As Long) As Boolean
Private Declare Function FtpPutFile Lib "wininet.dll" Alias _
"FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, _
ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean
'To send a file
Public Function FtpUpload(SourceFile As String, DestFile As String)
Dim HwndConnect As Long
Dim HwndOpen As Long
'Open internet
HwndOpen = InternetOpen("SiteWeb", 0, vbNullString, vbNullString, 0)
'Connection to ftp
HwndConnect = InternetConnect(HwndOpen, "111.111.44.55", 21, "ubuntu", "Password", 1, 0, 0)
FtpSetCurrentDirectory HwndConnect, "/home/ubuntu/ftp/files"
'Send file "SourceFile" and rename it "DestiFile" on the server
FtpPutFile HwndConnect, SourceFile, DestFile, &H0, 0
InternetCloseHandle HwndConnect 'close connection
InternetCloseHandle HwndOpen 'close internet
End Function
It works fine.
Now I need to add a progress bar to let the users know that the app is still working and isn't just dead. Something that will start at the beginning of this procedure and end at his end.
Thanks in advance.