0

I am trying to code a program that will go into a website, set a text value to a textbox from this website (which I got the ID), then click in a button. This is how I've codded it:

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim url As String = "https://jucemg.mg.gov.br/ibr"
        Dim Webb As New WebBrowser
        Webb.Navigate(url)
        Webb.ScriptErrorsSuppressed = True
        Webb.Document.GetElementById("numprotocolo").SetAttribute("value", TextBox1.Text)
        Webb.Document.GetElementById("consultar1").InvokeMember("click")
    End Sub
End Class

However, when I run it it gives me a System.NullReferenceException. It says that the WebBrowser.Document.Get has returned Nothing.

What is going wrong with this code?

Also I haven't created a webbrowser in my program, as it is supposed to perform the tasks without the user seeing it, and then just return a value that the website will later give.

Thanks alot!

0 Answers0