Motortracker
01-05-2008, 10:29 PM
ok i am trying to download multiple files at a time using Inet.
so on form2 i am using inet1. the file starts downloading just fine. then i changed inet1 to inet2 on form3. thinking that would let me download 2 files using 2 different inets. but as soon as inet2 starts downloading it stops inet1 from downloading.
Form1
Private Sub Command1_Click()
Do until i = 2
If Form2.Visible = False Then
Url = "www.someurl.com/test.txt
Filename = test.txt
Form2.Show
Else
Url = "www.someurl.com/test2.txt
Filename = test2.txt
Form3.Show
Loop
End If
End Sub
Form2
Private Sub Form_Load()
Sec = 1
SaveLocation = "C:\" & FileName
Download
End Sub
Private Sub Download()
Timer1.Enabled = True
Command1.Enabled = False
'start download
Inet1.Execute Trim$(Url), "GET"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim Buffer() As Byte 'buffer for receiving data from inet control.
On Error Resume Next
Select Case State
Case icResponseCompleted
Open SaveLocation For Binary As #1 'open output file
Do
DoEvents
Buffer = Inet1.GetChunk(512, icByteArray) 'get the data chunk
If UBound(Buffer) = -1 Then Exit Do 'no more data
Put #1, , Buffer 'write data to file
ProgressBar1.Value = Seek(1) - 1 'ammount of data downloaded
' Label1.Caption = "Downloaded " & ProgressBar1.Value \ 1024 & " kb, " & _
' FormatPercent(ProgressBar1.Value / ProgressBar1.Max)
Loop
Close
Picture = LoadPicture(SaveLocation) 'display the downloaded image
Case icResponseReceived
If LenB(Inet1.GetHeader("Content-Length")) > 0 Then
ProgressBar1.Max = CLng(Inet1.GetHeader("Content-Length")) 'total size
End If
End Select
End Sub
Form3
Private Sub Form_Load()
Sec = 1
SaveLocation = "C:\" & FileName
Download
End Sub
Private Sub Download()
Timer1.Enabled = True
Command1.Enabled = False
'start download
Inet2.Execute Trim$(Url), "GET"
End Sub
Private Sub Inet2_StateChanged(ByVal State As Integer)
Dim Buffer() As Byte 'buffer for receiving data from inet control.
On Error Resume Next
Select Case State
Case icResponseCompleted
Open SaveLocation For Binary As #1 'open output file
Do
DoEvents
Buffer = Inet2.GetChunk(512, icByteArray) 'get the data chunk
If UBound(Buffer) = -1 Then Exit Do 'no more data
Put #1, , Buffer 'write data to file
ProgressBar1.Value = Seek(1) - 1 'ammount of data downloaded
' Label1.Caption = "Downloaded " & ProgressBar1.Value \ 1024 & " kb, " & _
' FormatPercent(ProgressBar1.Value / ProgressBar1.Max)
Loop
Close
Picture = LoadPicture(SaveLocation) 'display the downloaded image
Case icResponseReceived
If LenB(Inet2.GetHeader("Content-Length")) > 0 Then
ProgressBar1.Max = CLng(Inet2.GetHeader("Content-Length")) 'total size
End If
End Select
End Sub
so on form2 i am using inet1. the file starts downloading just fine. then i changed inet1 to inet2 on form3. thinking that would let me download 2 files using 2 different inets. but as soon as inet2 starts downloading it stops inet1 from downloading.
Form1
Private Sub Command1_Click()
Do until i = 2
If Form2.Visible = False Then
Url = "www.someurl.com/test.txt
Filename = test.txt
Form2.Show
Else
Url = "www.someurl.com/test2.txt
Filename = test2.txt
Form3.Show
Loop
End If
End Sub
Form2
Private Sub Form_Load()
Sec = 1
SaveLocation = "C:\" & FileName
Download
End Sub
Private Sub Download()
Timer1.Enabled = True
Command1.Enabled = False
'start download
Inet1.Execute Trim$(Url), "GET"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim Buffer() As Byte 'buffer for receiving data from inet control.
On Error Resume Next
Select Case State
Case icResponseCompleted
Open SaveLocation For Binary As #1 'open output file
Do
DoEvents
Buffer = Inet1.GetChunk(512, icByteArray) 'get the data chunk
If UBound(Buffer) = -1 Then Exit Do 'no more data
Put #1, , Buffer 'write data to file
ProgressBar1.Value = Seek(1) - 1 'ammount of data downloaded
' Label1.Caption = "Downloaded " & ProgressBar1.Value \ 1024 & " kb, " & _
' FormatPercent(ProgressBar1.Value / ProgressBar1.Max)
Loop
Close
Picture = LoadPicture(SaveLocation) 'display the downloaded image
Case icResponseReceived
If LenB(Inet1.GetHeader("Content-Length")) > 0 Then
ProgressBar1.Max = CLng(Inet1.GetHeader("Content-Length")) 'total size
End If
End Select
End Sub
Form3
Private Sub Form_Load()
Sec = 1
SaveLocation = "C:\" & FileName
Download
End Sub
Private Sub Download()
Timer1.Enabled = True
Command1.Enabled = False
'start download
Inet2.Execute Trim$(Url), "GET"
End Sub
Private Sub Inet2_StateChanged(ByVal State As Integer)
Dim Buffer() As Byte 'buffer for receiving data from inet control.
On Error Resume Next
Select Case State
Case icResponseCompleted
Open SaveLocation For Binary As #1 'open output file
Do
DoEvents
Buffer = Inet2.GetChunk(512, icByteArray) 'get the data chunk
If UBound(Buffer) = -1 Then Exit Do 'no more data
Put #1, , Buffer 'write data to file
ProgressBar1.Value = Seek(1) - 1 'ammount of data downloaded
' Label1.Caption = "Downloaded " & ProgressBar1.Value \ 1024 & " kb, " & _
' FormatPercent(ProgressBar1.Value / ProgressBar1.Max)
Loop
Close
Picture = LoadPicture(SaveLocation) 'display the downloaded image
Case icResponseReceived
If LenB(Inet2.GetHeader("Content-Length")) > 0 Then
ProgressBar1.Max = CLng(Inet2.GetHeader("Content-Length")) 'total size
End If
End Select
End Sub