How do I get the tabPages to save in the correct order from low to high using getNextControl()

I am using the code below to save data from the controls to a text file. The controls are saving in the tabIndex order correctly. However, there are multiple tabPages and they seem to be saving in reverse order.

   The controls from tabpage 10 saves in the indexed order then tabpage 9, 8, 7,....

I want the tabPages to save from low to high then the tab index...

 Dim cntrl As Control = Me
         cntrl = Me.GetNextControl(cntrl, True)
         If TypeOf cntrl Is TextBox Then
                 outputFile.wplWriteLine(cntrl.Name, Trim(cntrl.Text))
          End If
         ......other code here.....
 End Using
Natavia FinnieSenior Analyst Technical Focus ApplicationsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duy PhamFreelance IT ConsultantCommented:
Maybe you could iterate the TabPages in correct order (1, 2, ..., 10) and then save each and every controls in each TabPage following tabIndex order.

Sample pseudo code:
Dim cntrl As Control
Dim I As Integer

For I = 0 To Me.tabControl.TabPages.Count
    cntrl = Me.tabControl.TabPages(I)
         cntrl = Me.GetNextControl(cntrl, True)
          If TypeOf cntrl Is TextBox Then
                  outputFile.wplWriteLine(cntrl.Name, Trim(cntrl.Text))
           End If
          ......other code here.....
    While Not (cntrl Is Nothing) And (cntrl.Parent <> Me.tabControl.TabPages(I))
Next I

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Natavia FinnieSenior Analyst Technical Focus ApplicationsAuthor Commented:

Thank you, thank you, thank you........
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.