...

View Full Version : Resolved Visual Basic 2012 RC2



kor81
08-10-2012, 07:43 PM
Is this bugged? most of my code doesn't trigger if it isn't in a timer. I Building me a dashboard for researching keywords/niches. I Know there are many great research tools out there but none of the features i'm looking for and i don't like automation for keyword researching...


I Have this code in a command button


Private Sub b1_Click(sender As Object, e As EventArgs) Handles b1.Click
WebBrowser1.Navigate("https://www.google.com/#hl=en&gs_nf=1&tok=HgkeOWqkbX4JBAdAvOo9Vg&cp=8&gs_id=1w&xhr=t&q=" & SeedKW.Text & "&pf=p&output=search&sclient=psy-ab&oq=asdasdas&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=3caf70095441cb5a&biw=1366&bih=643")

Do Until Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop

kwharvest.harvest()

End Sub


This calls this form a Module



Public Sub harvest()

Dim theElementCollection As HtmlElementCollection = kiword.WebBrowser1.Document.GetElementsByTagName("div")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("id").Contains("botstuff") Then
kiword.RichTextBox1.Text += curElement.GetAttribute("innerText") & vbCrLf
Exit Sub
End If
Next
End Sub


But the code wont fire unless i click the command button twice, then it fires the code or if i take the code from the Module and put it in a timer and set the interval to 1000 then it fires on a single click from the command button.

I'm pretty sure that it's this


Do Until kiword.WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop

But I've used this so many times in prior versions and never failed to work and with all the problems i'm now having, i'm starting to think that it's VB.NET 2012.

I'm re-installing 2010 to see if that fixes all my problems.

kor81
08-10-2012, 09:01 PM
This is the onlyway i could come up with to get it to work correctly everytime.


Private Sub b1_Click(sender As Object, e As EventArgs) Handles b1.Click

Label4.Text = ""

WebBrowser1.Navigate("https://www.google.com/#hl=en&gs_nf=1&tok=HgkeOWqkbX4JBAdAvOo9Vg&cp=8&gs_id=1w&xhr=t&q=" & SeedKW.Text & "&pf=p&output=search&sclient=psy-ab&oq=asdasdas&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=3caf70095441cb5a&biw=1366&bih=643")

Do Until Label4.Text = "Search"
Application.DoEvents()
Dim theElementCollection As HtmlElementCollection = Me.WebBrowser1.Document.GetElementsByTagName("div")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("id").Contains("ab_name") Then
Me.Label4.Text += curElement.GetAttribute("innerText") & vbCrLf
kwharvest.harvest()
Exit Sub
End If
Next
Loop


End Sub



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum