0
Private Sub Form_Load()
Dim tmp() As String
Dim i As Integer
Open App.Path & "\links.txt" For Input As #1
    tmp() = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For i = 0 To UBound(tmp)
DL.Download tmp(i), App.Path & "\" & ExtractFileName(tmp(i)), "k" & i
Label2.Caption = "Connecting..."
Next i
End Sub

Private Function ExtractFileName(ByVal vStrFullPath As String) As String
   Dim intPos As Integer
   intPos = InStrRev(vStrFullPath, "/")
   ExtractFileName = Mid$(vStrFullPath, intPos + 1)
End Function

The Problem is that I put about 4 links in the text file, and when I run the application it downloads them all at once, I would like it if it downloads them one at a time and about 2 minutes delay between downloading, so when one file is downloaded it will then wait 2 minutes then start downloading the next.

3
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by Jishnu
0

Write this code in the declaration section:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Then suppose you want a delay of 2 minutes, then convert it into milliseconds, i.e. 120000.

Sleep(120000)
0

so, where abouts do I put it in,

Private Sub Form_Load()
Dim tmp() As String
Dim i As Integer
Open App.Path & "\links.txt" For Input As #1
tmp() = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For i = 0 To UBound(tmp)
DL.Download tmp(i), App.Path & "\" & ExtractFileName(tmp(i)), "k" & i
Label2.Caption = "Connecting..."
Next i
End Sub

Private Function ExtractFileName(ByVal vStrFullPath As String) As String
Dim intPos As Integer
intPos = InStrRev(vStrFullPath, "/")
ExtractFileName = Mid$(vStrFullPath, intPos + 1)
End Function

0
Private Sub Form_Load()
Dim tmp() As String
Dim i As Integer
Open App.Path & "\links.txt" For Input As #1
    tmp() = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For i = 0 To UBound(tmp)
DL.Download tmp(i), App.Path & "\" & ExtractFileName(tmp(i)), "k" & i
Label2.Caption = "Connecting..."
Next i
End Sub

Private Function ExtractFileName(ByVal vStrFullPath As String) As String
   Dim intPos As Integer
   intPos = InStrRev(vStrFullPath, "/")
   ExtractFileName = Mid$(vStrFullPath, intPos + 1)
End Function

The Problem is that I put about 4 links in the text file, and when I run the application it downloads them all at once, I would like it if it downloads them one at a time and about 2 minutes delay between downloading, so when one file is downloaded it will then wait 2 minutes then start downloading the next.

Hi,
Sleep () helps you to give the delay.
1000 milliseconds represent one Second
so for 2 minutes 1000 * 60 * 2 = 120000
Declare the Sleep() at the Top. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Form_Load()
Dim tmp() As String
Dim i As Integer
Open App.Path & "\links.txt" For Input As #1
    tmp() = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For i = 0 To UBound(tmp)
DL.Download tmp(i), App.Path & "\" & ExtractFileName(tmp(i)), "k" & i
Label2.Caption = "Connecting..."
[B]Call Sleep ( 120000 )[/B]
Next i
End Sub

Private Function ExtractFileName(ByVal vStrFullPath As String) As String
   Dim intPos As Integer
   intPos = InStrRev(vStrFullPath, "/")
   ExtractFileName = Mid$(vStrFullPath, intPos + 1)
End Function

Note:
Until 2 minutes complete, your program will be idle, even u cannot maximize,minimise and moving.It wont receive any input. Using Timer may be the good solution.

0

Using Timer may be the good solution.

Agreed. That is more practicable for such long delays.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.