|
-
Jan 14th, 2012, 10:26 PM
#1
Thread Starter
Addicted Member
need help with loop in search engine finder code
Ran into a problem. My for loop seems to stop after just for the task. I can't seem how to get it to continue on, I've used this type of loop many times and have never had this problem. Any suggestions?
Code:
Imports System.Net
Imports System.Text.RegularExpressions
Public Class Form1
Dim sites As String = Nothing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.AddRange(TextBox1.Text.Split(Environment.NewLine))
TextBox1.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim pages As Integer = 1
Dim p As Integer = 0
Dim source As String
For i = 0 To ListBox1.Items.Count - 1
RichTextBox1.Text = RichTextBox1.Text + ListBox1.Items.Item(i)
Do Until p = NumericUpDown1.Value
Dim wc As New WebClient
source = wc.DownloadString("http://www.bing.com/search?q=" & ListBox1.Items.Item(i) & "&go=&qs=n&sk=&sc=4-13&first=" & pages & "&FORM=PERE")
sites = sites + source
links(i)
pages += 10
p += 1
Loop
source = Nothing
Next
End Sub
Private Sub links(ByVal i As Integer)
Dim links As MatchCollection = Regex.Matches(sites, "(http|https):\/\/([\w\-_\.]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?", RegexOptions.Singleline + RegexOptions.IgnoreCase)
For Each link As Match In links
Dim value As String = link.Groups(0).Value
If value.Contains(ListBox1.Items.Item(i)) Then
RichTextBox1.Text = RichTextBox1.Text + value + vbNewLine
End If
Next
End Sub
End Class
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Jan 15th, 2012, 05:17 AM
#2
Hyperactive Member
Re: need help with loop in search engine finder code
At first glance it looks to me like, you need to reset 'p' to when you drop out of the 'Do Until loop'. On the Next 'For Loop' 'p' is already equal to NumericUpDown.Value and so won't perform the Do Until.
Where you have source = nothing, add on a new line p = 0 and see if that works
Cheers
Dan
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|