Reputation: 839
I have a vb.net (windows) project download from internet. It is in vb.net and it has user controls. This project contains a single form alone and this form uses user control. But the error is Object reference not set to an instance of an object. Use the "new" keyword to create object instance.
Upvotes: 0
Views: 3405
Reputation: 2553
It sounds like the code is adding a control dynamically...
Dim myControl as myUserControl
myControl.name = "control1"
'+ any other properties set
myForm.Controls.Add(myControl)
This will give the error you have seen...
Dim myControl as New myUserControl
myControl.name = "control1"
'+ any other properties set
myForm.Controls.Add(myControl)
Would be the fix - This is how you can add may instances of the same control... just make sure they have unique names.
Upvotes: 1