troubleshooting Question

Sleeping in VB6

Avatar of JoeD77
JoeD77 asked on
Visual Basic ClassicVisual Basic.NET
5 Comments1 Solution643 ViewsLast Modified:
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()

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
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
Mike Tomlinson
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2009

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros