Exception:
Object reference not set to an instance of an object.
Code:
For Each p As Panel In Me.Controls.OfType(Of Panel)()
arr.Add(p.BackColor.ToString())
Me.Controls.Remove(p)
Next
The line:
arr.Add(p.BackColor.ToString())
How can I fix this thing?
You probably declared
arrsomething like this:You need to initialize the variable to an instance of
List(Of String)before you can use it. Change it to: