VB.NET - NullReferenceError was Unhandled when I use text from a different form -
I am trying to create a program where people can upload text to the database. I am using a weboborzer to accomplish this, when the code tries to use text in another way, it creates a null reference when I try to run the code in debug.
This is my current code when uploading in the form:
Public class form 2 private sub form 2_load (Systems like System, Object, Adventurer) mbabes Load Webborder 1. Navigate ("http: /database.insma.org/") WebBrowser1.AllowNavigation = True End Sub Handle Personal Button1_Click (as System.Object, E. System.EventArgs) Handle Button1.Click WebBrowser1.Document. GetElementById ("name"). SetAttribute ("Value", TextBox1.Text) WebBrowser1.Document.GetElementById ("Passed") setAttribute (. "Value", TextBox2.Text) WebBrowser1.Document.GetElementById ("Edit-Presented - 2".) InvokeMember ("Clicks ") Threading.Thread.Sleep (1000) WebBrowser1.AllowNavigation = True WebBrowser1.Navigate (" http://database.insma.org/?q=node/add/log ") Threading.Thread.Sleep (1000) WebBrowser1 Document. Gette lementById ("title"). SetAttribute ("value", Form1.TextBox2.Text) WebBrowser1.Document.GetElementById ("field_time_utc_ [und] [0], [value]"). SetAttribute ("value", Form1.TextBox4.Text) WebBrowser1.Document.GetElementById ("field_location_ex_utwente_hong_k [und] [0], [value]"). SetAttribute ("value", Form1.TextBox5.Text) WebBrowser1.Document.GetElementById ("field_frequency [und] [0], [value]") .SetAttribute ("value", Form1.TextBox3.Text) WebBrowser1.Document.GetElementById ("FIELD_ID [und] [0], [value]"). SetAttribute ("value", Form1.TextBox6.Text) WebBrowser1.Document .GetElementById ("field_call_up [und] [0], [value]"). SetAttribute ("value", Form1.TextBox7.Text) WebBrowser1.Document.GetElementById ("field_group_count [und] [0], [value]"). SetAttribute ("value", Form1.TextBox8.Text) WebBrowser1.Document.GetElementById ("body [und] [0], [value]"). SetAttribute ("value", Form1.TextBox1.Text) WebBrowser1.Document.GetElementById ("edit"). InvokeMember ( "upload click") Threading.Thread.Sleep (1000) MsgBox ( "Database") End Sub P rivate sub WebBrowser1_DocumentCompleted (ByVal as System.Object, ByVal e System.Windows.Forms.WebBrowserDocumentCompletedEventArgs End Sub Ending Class This is how the error looks like:
It would be greatly appreciated if you do it dumb for me when you Explaining what is happening because I can not understand what people are trying to do.
With the solution to me error!
Thank you, Weighted Cube
Just Embrace Your Class Instance, Write It:
public class form 2 Dim form 1 New form 1) as the system as a private sub form 2_lod (sender. object, and as a system. Aventarj) Mabbes. Load Webborder 1. Navigate ("http://database.insma.org/") WebBrowser1.AllowNavigation = True End Sub Handle Personal Button1_Click (as System.Object, E. System.EventArgs) Handle Button1.Click WebBrowser1.Document. GetElementById ("name") .SetAttribute ("value", text tBox1.Text) WebBrowser1.Document.GetElementById ("passed") setAttribute ("value", TextBox2.Text) WebBrowser1.Document.GetElementById ("edit-present-2 "..) InvokeMember (" click ") Threading.Thread .Sleep (1000) WebBrowser1.AllowNavigation = True WebBrowser1.Navigate (" http://database.insma.org/?q=node/add/log ") Threading. Thread.Sleep (1000) WebBrowser1.Document.GetElementById ("title"). SetAttribute ("value", Form1.TextBox2.Text) WebBrowser1.Document.GetElementById ("field_time_utc_ [und] [0], [value]"). SetAttribute ("value", Form1.TextBox4.Text) WebBrowser1. Document.getElementById ("field_location_ex_utwente_hong_k [und] [0], [value]"). SetAttribute ("value", Form1.TextBox5.Text) WebBrowser1.Document.GetElementById ("field_frequency [und] [0], [value]"). SetAttribute ("value", Form1.TextBox3.Text) WebBrowser1.Document.GetElementById ("FIELD_ID [und] [0], [value]"). setAttribute ( "value", FormlkTextBox6kText) WebBrowserlkDocumentkGetElementById ( "Fild_ call_up [und] [0] [value]") Settetivet ( "value" form 1.TextBox7.Text) WebBrowser1 .Document.GetElementById ( "Field_group_count [und] [0], [value]"). SetAttribute ( "value", Form1.TextBox8.Text) WebBrowser1.Document.GetElementById ( "body [und] [0], [value]") .SetAttribute ( "value", Form1.TextBox1.Text) WebBrowser1.Document.GetElementById ("Send to edit"). InvokeMember ( "click") Threading.Thread.Sleep (1000) went to upload MsgBox ( "database!") End Sub Private Sub WebBrowser1_DocumentCompleted (ByVal as the System.Object, ByVal e System.Windows.Forms.WebBrowserDocumentCompletedEventArgs End Sub End Class
Comments
Post a Comment