Results 1 to 3 of 3

Thread: using a conditional loop

  1. #1
    Water's Avatar
    Joined
    Nov 2012
    Posts
    792
    Userbars
    12
    Thanks
    474
    Thanked
    452/210
    DL/UL
    158/9
    Mentioned
    217 times
    Time Online
    54d 8h 42m
    Avg. Time Online
    18m

    using a conditional loop

    Code:
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            Dim HTML = thewrapper.Request("GET", "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text(), "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text())
            Dim NC = GetStringBetween(HTML, "; background-color", "<B>&laquo; Previous page")
            Dim items = GBA(NC, "id=", "</B>", ListBox1)
            If HTML.Contains("Next Page'must use something else") Then
                For a = 20 To 10000 + 20
                    Dim HTMLs = thewrapper.Request("GET", "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text & "&start=" & a, "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text())
                    Dim NCs = GetStringBetween(HTMLs, "; background-color", "<B>&laquo; Previous page")
                    Dim itemss = GBA(NCs, "id=", "</B>", ListBox1)
                Next
            ElseIf
               MessageBox.Show("All Pages viewed")
            End If
    
        End Sub
    I know the If statement is totally wrong :/

    Code:
    For counter [ As datatype ] = start To end [ Step step ]
        [ statements ]
        [ Continue For ]
        [ statements ]
        [ Exit For ]
        [ statements ]
    Next [ counter ]
    I was trying to focus on a path ect for said thing to occur for the condition.
    I'm trying to go to the next page until there is no longer a next page

    Would it be best to use a While Loop instead?
    Or should I stick to using the while loop to make the request go to the next page?

    Thanks

  2. #2

    Joined
    Jul 2012
    Posts
    1,888
    Thanks
    1,619
    Thanked
    3,297/1,003
    DL/UL
    223/0
    Mentioned
    469 times
    Time Online
    132d 23h 52m
    Avg. Time Online
    45m
    Quote Originally Posted by Water View Post
    Code:
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            Dim HTML = thewrapper.Request("GET", "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text(), "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text())
            Dim NC = GetStringBetween(HTML, "; background-color", "<B>� Previous page")
            Dim items = GBA(NC, "id=", "</B>", ListBox1)
            If HTML.Contains("Next Page'must use something else") Then
                For a = 20 To 10000 + 20
                    Dim HTMLs = thewrapper.Request("GET", "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text & "&start=" & a, "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text())
                    Dim NCs = GetStringBetween(HTMLs, "; background-color", "<B>� Previous page")
                    Dim itemss = GBA(NCs, "id=", "</B>", ListBox1)
                Next
            ElseIf
               MessageBox.Show("All Pages viewed")
            End If
    
        End Sub
    I know the If statement is totally wrong :/

    Code:
    For counter [ As datatype ] = start To end [ Step step ]
        [ statements ]
        [ Continue For ]
        [ statements ]
        [ Exit For ]
        [ statements ]
    Next [ counter ]
    I was trying to focus on a path ect for said thing to occur for the condition.
    I'm trying to go to the next page until there is no longer a next page

    Would it be best to use a While Loop instead?
    Or should I stick to using the while loop to make the request go to the next page?

    Thanks
    What about:

    Code:
    while "<b>Next page �</b>" in HTML:
        nextPage = nextPage + 20
    It just saves you 2 or 3 lines of code but it's something.

    Where's this by the way?
    Next Page'must use something else

  3. #3
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    Code:
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Dim url = "http://www.neopets.com/ncma/index.phtml?user=" & TextBox1.Text
        Dim pageindex = 0
        Do
            Dim HTML = thewrapper.Request("GET", url & "&start=" & pageindex, url)
            Dim NC = GetStringBetween(HTML, "; background-color", "<B>� Previous page")
            GBA(NC, "id=", "</B>", ListBox1)
            pageindex += 20
        Loop While HTML.Contains(<b>Next page �</b>)
       
       MessageBox.Show("All Pages viewed")
    End Sub
    @(you need an account to see links)

    Assuming &start=0 is a valid page, you can just start your loop at start=0, visit that page, grab the items, increase the &start= by 20. This loops while there is a Next Page

Posting Permissions

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