Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    57
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Visual Basic 2012 RC2

    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

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


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

    Code:
    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.
    Last edited by kor81; 08-10-2012 at 11:04 PM.

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    57
    Thanks
    11
    Thanked 0 Times in 0 Posts
    This is the onlyway i could come up with to get it to work correctly everytime.

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


  •  

    Posting Permissions

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