I start to make a new application to detect all html elements on a webpage in this example i use yahoo
But i get null exception this is the error
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=autoclic
StackTrace:
at autoclic.Form1.Button1_Click(Object sender, EventArgs e) in
c:\users\monchique discovery\documents\visual studio
2012\Projects\autoclic\autoclic\Form1.vb:line 7
I can not figure out how to solve this null exception
this is my code
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.WebBrowser1.Navigate(New Uri("http://www.yahoo.com"))
Me.ListBox1.Items.Add("Type" & "-->" & "Name")
For Each element As HtmlElement In Me.WebBrowser1.document.All
Me.ListBox1.Items.Add(element.TagName() & "-->" & element.Id)
Next
If Me.WebBrowser1.Document.All Is Nothing Then
Return
End If
End Sub
End Class