PDA

View Full Version : using a conditional loop



Water
02-01-2016, 01:43 AM
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim HTML = thewrapper.Request("GET", "[Only registered and activated users can see links]" & TextBox1.Text(), "[Only registered and activated users can see links]" & 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", "[Only registered and activated users can see links]" & TextBox1.Text & "&start=" & a, "[Only registered and activated users can see links]" & 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 :/


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 :)

Daviid
02-07-2016, 12:03 PM
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim HTML = thewrapper.Request("GET", "[Only registered and activated users can see links]" & TextBox1.Text(), "[Only registered and activated users can see links]" & 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", "[Only registered and activated users can see links]" & TextBox1.Text & "&start=" & a, "[Only registered and activated users can see links]" & 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 :/


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:


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

Zachafer
02-11-2016, 01:06 AM
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim url = "[Only registered and activated users can see links]" & 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")
[Only registered and activated users can 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