Depends. What operating system? For MS-Windows, do you want to use pure win32 api functions? If yes, here is a tutorial. But there are a lot easier ways to write gui programs nowdays. Two of them is CLR/C++ Windows Forms, and C# instead of C.
If you are thinking *nix, then look into low-level X11R6 (there are lots of books on that) or Motief. Again, C++ gives you more and easier options, sich as wxWidgets.
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 ...