Either you can use an if statement to check if the element you are retrieving is null or you have to keep a record of the size of the populated array for your condition of the loop instead of the size of the array.
do you understand what null is? it's the default value for a non-instantiated but declared Object.
since it has no value (yet) you can't call a method on it.
there are two ways to avoid this from happening:
1. add an conditional statement, checking whether or not the element you're trying to work with is null or not (as been suggested earlier)
2. make sure your array doesn't contain any null values.
String myArrray = new String;
for ( int i = 0; i < myArray.length; i++)
myArray[i] = new String("");
off course, this is just a very basic example, but even though all the String-elements of myArray are an empty String (and you can decide on what your default value could/should be in your case), none of them will cause a null pointer exception.
stultuske is giving you good advice, so you should make more effort to follow it rather than wasting his time. Your latest code completely fails to implement the perfectly good solution that he gave you earlier. Re-read his posts and think carefully about what he says..
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...