Ok, the problem is that you declared the variable (msg) as a boolean value.... while the msgbox function returns more values than just true and false. This code works wonderfully when you change the type declaration of your variable:
Dim msg As VbMsgBoxResult
msg = MsgBox("Save this one?", vbYesNo)
If msg = vbYes Then
Declaring variables isn't required in VB, but it's a great practice. Part of the reason is, when you get into other languages, that are more powerful, you'll be forced to declare any variable before you can use it.... also, declaring variables provides the program with a reserve of memory for that variable. This makes your program smaller, and makes it run faster. On a simple test application, like the one we have here, it won't make a noticable difference, but in larger applications, you'll be asking yourself what the hell happened. Provided is a link to a page that will help you to optimize your VB programming, so that you can increase the speed significantly of yours apps.
Also, When you don't declare a variable, it's default type is a variant. If you read the page linked, you'll see why variants are a no, no. Basically, they are the largest, most bulky variable type in existance, and should really be treated like the Leper Variable. In fact, every time you use a variant type variable, I want you to think about how you are giving your code leprosy.
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 ...