Results 1 to 5 of 5

Thread: For Statement help needed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377

    Question For Statement help needed

    i'm trying to get this coding to go back the the For W statement after ClickLink then to Next i then keep repeating till there is no page with "Next ->" link on it.


    Private Sub Command1_Click()

    Dim W As Integer
    For W = 0 To Web1.Document.links.length - 1
    'Debug.Print Web1.Document.links(X)
    lstautolink.AddItem Web1.Document.links(W)
    Next W

    Dim i As Integer
    For i = lstautolink.ListCount - 1 To 0 Step -1
    If InStr(1, lstautolink.List(i), "mp3s") = 0 Then
    lstautolink.RemoveItem (i)
    End If
    Next i

    ClickLink Web1.Document, "Next ->"

    Do
    DoEvents
    Loop Until Not Web1.Busy

    Msgbox "No more Next-> links"

    End Sub

  2. #2
    Lively Member dlm's Avatar
    Join Date
    Oct 2000
    Location
    Geraardsbergen(Belgium)
    Posts
    91
    Hi there,

    Have you tried to work with labels and GoTo...?


    Code:
    Next_W:
        For W = 0 To Web1.Document.links.length - 1 
             'Debug.Print Web1.Document.links(X) 
             lstautolink.AddItem Web1.Document.links(W) 
        Next W 
    
    Next_I:
        Dim i As Integer 
        For i = lstautolink.ListCount - 1 To 0 Step -1 
              If InStr(1, lstautolink.List(i), "mp3s") = 0 Then 
                   lstautolink.RemoveItem (i) 
              End If 
        Next i 
    
        GoTo Next_W
    If you can solve the problem, why worrying about it…
    If you can’t solve the problem, worrying won’t help…

    De la Motte Günther

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377
    is there another way of doing this without GoTo, by just using the For Statement

  4. #4
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    you mean structured like this:

    VB Code:
    1. For W = 0 To Web1.Document.links.length - 1
    2.      'Debug.Print Web1.Document.links(X)
    3.      lstautolink.AddItem Web1.Document.links(W)
    4.  
    5.     Dim i As Integer
    6.     For i = lstautolink.ListCount - 1 To 0 Step -1
    7.           If InStr(1, lstautolink.List(i), "mp3s") = 0 Then
    8.                lstautolink.RemoveItem (i)
    9.           End If
    10.     Next i
    11. Next W
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  5. #5
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking Kites are a good thing...r they not?

    VB Code:
    1. Private Sub NextW()
    2. Dim W As Integer    
    3.     For W = 0 To Web1.Document.links.length - 1
    4.          'Debug.Print Web1.Document.links(X)
    5.          lstautolink.AddItem Web1.Document.links(W)
    6.     Next W
    7. End Sub

    Do the same for the other one, then just keep caklling the procedures....

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