Posted on: 1/15/2014 6:08:54 PM | Views : 604

I have three textboxes and one button.
Textbox1: _______       textbox2: _______   textbox3: ________      |button|
“error:Object reference not set to an instance of an object. 
I know the cause of this error, it’s because textbox1 , textbox2 are required to fill in.
See the code below:
Dim dt As New DataTable() dt.Columns.Add("Name", GetType(String)) dt.Columns.Add("Address", GetType(String)) dt.Columns.Add("factory", GetType(String)) 'Loop through the data results ' and add the DataTable rows and load the values from the data (if textbox3 is filled in and textbox1 and textbox2 are blank the error display here on this line “ for each results in namefactory”) For Each results In NameFactory <--- error:Object r ...

Go to the complete details ...