I am trying to download a binary file using the internet transfer control using the .getchunk(...) so I can show progress. But it doesn't work. I have gone to a lot of sites on google but I can't seem to make it work. What doesn't work in particular is the Inet1_StateChanged(ByVal State As Integer) doesn't ever run, though its supposed to. I can't get the .Execute(...) to work though I can use the .OpenURL relatively successfully. I have so far:
' all undeclared variables are public
' backup_new.tmp is about 130 KB
Public Sub DownloadProgram()
Dim ByteArray() As Byte
FileName = "backup_new.tmp"
Inet1.URL = "[some arbitrary website]"
Inet1.Execute , "GET"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer) 'This doesn't run
On Error Resume Next
Dim sngProgerssValue As Single
Dim vtData As Variant
Select Case State
Case icResponseCompleted ' 12
Dim bDone As Boolean: bDone = False
Dim tempArray() As Byte
Max = Inet1.GetHeader("Content-length")
If Len(FileName) Then
Open FileName 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
If Len(vtData) = 0 Then
bDone = True
End If
Loop
Close #1
End If
' End Case
End Select
End Sub
____________________________________________________________________________
There are only 10 types of people in the world. Those that know binary and those that don't
Brent
' all undeclared variables are public
' backup_new.tmp is about 130 KB
Public Sub DownloadProgram()
Dim ByteArray() As Byte
FileName = "backup_new.tmp"
Inet1.URL = "[some arbitrary website]"
Inet1.Execute , "GET"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer) 'This doesn't run
On Error Resume Next
Dim sngProgerssValue As Single
Dim vtData As Variant
Select Case State
Case icResponseCompleted ' 12
Dim bDone As Boolean: bDone = False
Dim tempArray() As Byte
Max = Inet1.GetHeader("Content-length")
If Len(FileName) Then
Open FileName 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
If Len(vtData) = 0 Then
bDone = True
End If
Loop
Close #1
End If
' End Case
End Select
End Sub
____________________________________________________________________________
There are only 10 types of people in the world. Those that know binary and those that don't
Brent