Steph Nicolaou ..its never entering the "if" part, you can check that. and if it has entered then the program would have ended after returning 0..
and the best part of this program is, 5 is never getting Decremented . Might be post Decrement doesn't work with recursion as it doesn't work with return.
It has to do with the way the call reverse(no--) is being implemented. The post decrement operator allows for the variable to be used in it's context before it is decremented. So, in your situation it is using the original value of no for the recursive call and decrementing it after that (which never occurs). Change that to reverse(--no) or reverse(no - 1) and you will get the behavior you are after.
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 ...