Hi,
I'm just a beginner in VB6.
I have already written a code to get some files from an FTP server... and it works well.
But I just want to add a progress bar. I have some examples but they are to complex for me... (and the example is VB.NET. But I had seen the same code on a VB6 forum but i can't find it anymore...
I just want to add a progress bar to my little program. Thats all.
my prgm code in VB6:
form with 1 button (cmdtest)
Option Explicit
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 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 FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Sub cmdtest_Click()
'/////////////////// Veriabelen definieren ///////////////////'
Dim server As String, paswoord As String, username As String
server = "192.168.1.2"
username = "sukke"
paswoord = "jupiler666"
'/////////////////// Internet sessie starten ///////////////////'
Dim congelukt As Long
congelukt = InternetOpen(server, 1, vbNullString, vbNullString, 0)
If congelukt = 0 Then
MsgBox "connectie failed"
Exit Sub
End If
'/////////////////// Inloggen ///////////////////'
Dim coninlog As Long
coninlog = InternetConnect(congelukt, server, 0, _
username, paswoord, 1, 0, 0)
If coninlog = 0 Then
MsgBox "Inloggen Misslukt"
Exit Sub
End If
'/////////////////// File afhalen ///////////////////'
Dim condownload As Boolean
condownload = FtpGetFile(coninlog, "testfile.doc", "testfile.doc", 0, 0, 2, 0)
If condownload = False Then
MsgBox "Downloaden misslukt"
'Exit Sub
End If
'/////////////////// Inloggen ///////////////////'
InternetCloseHandle coninlog
InternetCloseHandle congelukt
End Sub
//////////////////////////////////////////////////
Could someone help me please? thx
mail: aswin.coolsaet@skynet.be
I'm just a beginner in VB6.
I have already written a code to get some files from an FTP server... and it works well.
But I just want to add a progress bar. I have some examples but they are to complex for me... (and the example is VB.NET. But I had seen the same code on a VB6 forum but i can't find it anymore...
I just want to add a progress bar to my little program. Thats all.
my prgm code in VB6:
form with 1 button (cmdtest)
Option Explicit
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 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 FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Sub cmdtest_Click()
'/////////////////// Veriabelen definieren ///////////////////'
Dim server As String, paswoord As String, username As String
server = "192.168.1.2"
username = "sukke"
paswoord = "jupiler666"
'/////////////////// Internet sessie starten ///////////////////'
Dim congelukt As Long
congelukt = InternetOpen(server, 1, vbNullString, vbNullString, 0)
If congelukt = 0 Then
MsgBox "connectie failed"
Exit Sub
End If
'/////////////////// Inloggen ///////////////////'
Dim coninlog As Long
coninlog = InternetConnect(congelukt, server, 0, _
username, paswoord, 1, 0, 0)
If coninlog = 0 Then
MsgBox "Inloggen Misslukt"
Exit Sub
End If
'/////////////////// File afhalen ///////////////////'
Dim condownload As Boolean
condownload = FtpGetFile(coninlog, "testfile.doc", "testfile.doc", 0, 0, 2, 0)
If condownload = False Then
MsgBox "Downloaden misslukt"
'Exit Sub
End If
'/////////////////// Inloggen ///////////////////'
InternetCloseHandle coninlog
InternetCloseHandle congelukt
End Sub
//////////////////////////////////////////////////
Could someone help me please? thx
mail: aswin.coolsaet@skynet.be