counted_ptr must be a template/generic type which is well designed.
//class foo object bar
// now count_ptr serves as a container that can accept and manipulate class
get back to the basis of generics.
send from my phone so its not a working code. just the righ path.
I quick google search reveals that counted_ptr is a pre-historic version of shared_ptr. Unless you are using a specific (old) library that requires the use of counted_ptr, I must say that you should prefer using the standard std::shared_ptr pointer, or it's equivalent in Boostboost::shared_ptr.
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 ...