PDA

Click to See Complete Forum and Search --> : Simple Loop problem


tarctor
Oct 29th, 2003, 11:13 PM
Private Sub cmdret_Click()
Dim n As Integer
n = "1"
myurl = "http://www.site.com/cgi-bin/locate.pl?id=" & n

Do While n < 1000
n = n + 1


WebBrowser1.Navigate2 (myurl)
Inet1.Protocol = icHTTP
Inet1.Execute CStr(txturl), "GET /"

While Inet1.StillExecuting
DoEvents

Wend
call command1
Loop
'MsgBox "Done"
End Sub


What I am trying to do is loop through and change "n" each time until "n" reaches 1000. Must call command 1 each time "n" changes. Any help is appreciated.

blindlizard
Oct 30th, 2003, 12:47 AM
Private Sub cmdret_Click()
Dim n As Integer

For n = 1 to 1000
n = n + 1
myurl = "http://www.site.com/cgi-bin/locate.pl?id=" & n

WebBrowser1.Navigate2 (myurl)
Inet1.Protocol = icHTTP
Inet1.Execute CStr(txturl), "GET /"

While Inet1.StillExecuting
DoEvents
Wend

Call command1
Next n
'MsgBox "Done"
End Sub

tarctor
Oct 30th, 2003, 06:07 PM
For some rreason When I use this "n" is changing from 1 to 3 to 5 and so on. What am I missing?

WorkHorse
Oct 30th, 2003, 08:17 PM
"Next n" automatically increments the value of n in a For..Next loop, so you don't need n=n+1 inside the loop. That just adds an extra increment causing the For...Next loop to increment by Step 2. :)

blindlizard
Oct 30th, 2003, 08:23 PM
Crap, I can't believe I missed that. Here try this:Private Sub cmdret_Click()
Dim n As Integer

For n = 1 to 1000
myurl = "http://www.site.com/cgi-bin/locate.pl?id=" & n

WebBrowser1.Navigate2 (myurl)
Inet1.Protocol = icHTTP
Inet1.Execute CStr(txturl), "GET /"

While Inet1.StillExecuting
DoEvents
Wend

Call command1
Next n
'MsgBox "Done"
End Sub