0
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


    WebBrowser1.Document.GetElementById("searchField").SetAttribute("value", "SalesRecordNumber")   ' Change Dropdown To "Sales Record Number"
    WebBrowser1.Document.GetElementById("searchValues").InnerText = TextBox1.Text   ' Set The Search Value To Textbox1
    WebBrowser1.Document.GetElementById("searchbutton").InvokeMember("click")       ' Click On The Search Button

    Dim yourObj As HtmlElement = (From ele As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a") Where ele.InnerText = TextBox1.Text Select ele).FirstOrDefault
    yourObj.InvokeMember("click")  ' Select The Sale Record Number
End Sub

On the click for the yourObj, i get a "An unhandled exception of type 'System.NullReferenceException'" error

HudsonWY
  • 55
  • 2
  • 12
  • `yourObj` is `Nothing` because there was no such element. Does it "work" if you remove `Where ele.InnerText = TextBox1.Text Select ele`. – Tim Schmelter Jun 22 '15 at 09:03
  • @TimSchmelter I need this part of the code as that will get the specific link that I need – HudsonWY Jun 22 '15 at 09:11

0 Answers0