Results 1 to 5 of 5

Thread: Simple Loop problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    92

    Simple Loop problem

    Code:
    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.
    Last edited by tarctor; Oct 30th, 2003 at 12:19 AM.

  2. #2
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141
    VB Code:
    1. Private Sub cmdret_Click()
    2. Dim n As Integer
    3.  
    4. For n = 1 to 1000
    5.    n = n + 1
    6.    myurl = "http://www.site.com/cgi-bin/locate.pl?id=" & n
    7.  
    8.    WebBrowser1.Navigate2 (myurl)
    9.    Inet1.Protocol = icHTTP
    10.    Inet1.Execute CStr(txturl), "GET /"
    11.  
    12.    While Inet1.StillExecuting
    13.       DoEvents
    14.    Wend
    15.  
    16.    Call command1
    17. Next n
    18. 'MsgBox "Done"
    19. End Sub
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    92
    For some rreason When I use this "n" is changing from 1 to 3 to 5 and so on. What am I missing?

  4. #4
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    "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.

  5. #5
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141
    Crap, I can't believe I missed that. Here try this:
    VB Code:
    1. Private Sub cmdret_Click()
    2. Dim n As Integer
    3.  
    4. For n = 1 to 1000
    5.    myurl = "http://www.site.com/cgi-bin/locate.pl?id=" & n
    6.  
    7.    WebBrowser1.Navigate2 (myurl)
    8.    Inet1.Protocol = icHTTP
    9.    Inet1.Execute CStr(txturl), "GET /"
    10.  
    11.    While Inet1.StillExecuting
    12.       DoEvents
    13.    Wend
    14.  
    15.    Call command1
    16. Next n
    17. 'MsgBox "Done"
    18. End Sub
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width