Click to See Complete Forum and Search --> : Progress bar with a transferring file


Ryanitus
September 23rd, 2001, 02:15 PM
I am using the Inet control to transfer files between the local machine and an FTP site. I would like to have a progress bar showing the status of the file being sent/received. I know how to get the size of the file for the max value on the progres bar but is there a way to determine how much of the file has been sent/received already? Any links/tips/suggestions would be helpful, especially if it requires any kind of API call. Thanks :)

Ryan

dcaillouet
September 24th, 2001, 08:14 AM
I cut-and-pasted the example code out of the help file, added a couple of lines (look for the debug.print statement) and was able to come up with something close to what you need:


option Explicit

private Sub Form_Load()
INet1.Document = "PICS.FINANCE.JPG"
INet1.Execute , "get"
End Sub

private Sub Inet1_StateChanged(byval state as Integer)

Dim vtData as Variant
Dim strFileName as string
Dim lngLength as Long

Select Case state
' ... Other cases not shown.

Case icResponseCompleted ' 12
Dim bDone as Boolean: bDone = false
Dim tempArray() as Byte

strFileName = "E:\TestJunk.jpg"
Open strFileName for binary Access Write as #1

' get first chunk.
vtData = INet1.GetChunk(1024, icByteArray)
DoEvents

If len(vtData) = 0 then
bDone = true
End If

Do While Not bDone
tempArray = vtData
Put #1, , tempArray

' get next chunk.
vtData = INet1.GetChunk(1024, icByteArray)
DoEvents

lngLength = lngLength + 1024
Debug.print "Progress: " & lngLength

If len(vtData) = 0 then
bDone = true
End If
Loop

Close #1
End Select
End Sub

Boumxyz2
September 24th, 2001, 10:21 AM
Maybe you can calculate the received part so far and just divide the received file so far by the total size.. And then ask progress bar to show that percentage...

Nic