Arjeen
Regular Member
- Aug 22, 2012
- 294
- 16
Hei
i'm finishing my program (sorry for newbie) but there is one problem..
The program have to search the sentence on the ListBox1 and put in the WebBrowser, search and do it again, again, again, again..
But only for the first ListBox1.SelectItem work.. I don't know why..
This is my video problem:
http://www.youtube.com/watch?v=HUzvsq8Txq0
And this is my code:
The program have to search the sentence on the ListBox1 and put in the WebBrowser, search and do it again, again, again, again..
But only for the first ListBox1.SelectItem work.. I don't know why..
This is my video problem:
http://www.youtube.com/watch?v=HUzvsq8Txq0
And this is my code:
Code:
Private Sub ElectricButton2_Click(sender As Object, e As EventArgs) Handles ElectricButton2.Click WebBrowser1.Navigate("https://www.blurum.it/Web/")
Dim searchBox As HtmlElement = Nothing
Dim searchButton As HtmlElement = Nothing
searchBox = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search_bar_input")
searchButton = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search")
Do While WebBrowser1.Document Is Nothing OrElse searchBox Is Nothing OrElse searchButton Is Nothing
Application.DoEvents()
searchBox = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search_bar_input")
searchButton = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search")
Loop
Dim keyword As String = ListBox1.SelectedItem
searchBox.SetAttribute("value", keyword)
searchButton.InvokeMember("click")
WebBrowser1.Refresh()
For i As Integer = ListBox1.SelectedItems.Count - 1 To 0 Step -1
Dim k As Integer = ListBox1.SelectedIndices(i)
ListBox1.Items.RemoveAt(k)
Next
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Enabled = True
WebBrowser1.Navigate("https://www.blurum.it/Web/")
Dim searchBox As HtmlElement = Nothing
Dim searchButton As HtmlElement = Nothing
searchBox = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search_bar_input")
searchButton = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search")
Do While WebBrowser1.Document Is Nothing OrElse searchBox Is Nothing OrElse searchButton Is Nothing
Application.DoEvents()
searchBox = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search_bar_input")
searchButton = WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search")
Loop
Dim keyword As String = ListBox1.SelectedItem
searchBox.SetAttribute("value", keyword)
searchButton.InvokeMember("click")
WebBrowser1.Refresh()
For i As Integer = ListBox1.SelectedItems.Count - 1 To 0 Step -1
Dim k As Integer = ListBox1.SelectedIndices(i)
ListBox1.Items.RemoveAt(k)
Next
Dim asd = ListBox1.Items(0)
WebBrowser1.Document.GetElementsByTagName("input").OfType(Of HtmlElement)().FirstOrDefault(Function(p) p.GetAttribute("classname") = "search_bar_input").InnerText = (asd)
ListBox1.Items.RemoveAt(0)
Dim r as New Random
Timer1.Interval = r.Next(30000, 60000)
Timer1.Enabled = True
End Sub