Avatar of JoeD77
JoeD77

asked on 

Sleeping in VB6

Hi.
I'm trying to cycle through a text file, and using each line in that text file to launch a webpage (using WebBrowser.Navigate(TextOfLine)... The problem is, Sleep is not working properly, so the pages are cycled faster than they can load. I need each page to stay up for about 2 seconds before continuing.

Here's the code:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
Form1.Show
LaunchLineByLine

End Sub
Public Sub LaunchLineByLine()
Open "hosts.txt" For Input As #1
Line Input #1, a
'The very first line
MsgBox a
Do Until EOF(1)
Line Input #1, a
'subsequent lines
WebBrowser1.Navigate a
Sleep 2000
Loop
Close #1
End Sub

Open in new window


I know that Sleep is the problem because when I replace "Sleep 2000" with MsgBox a" (and hence breakpointing that loop execution), the page loads nicely as it should.

I need to be able to do this using Sleep, however.

Thanks in advance
Visual Basic ClassicVisual Basic.NET

Avatar of undefined
Last Comment
JoeD77

8/22/2022 - Mon