Link to home
Start Free TrialLog in
Avatar of Rocker4500
Rocker4500Flag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Clear All TextBoxes in Each TabPage

Ok, so im using VB.net and what i want to do is:

Clear every textbox on each tab page.

I have a Tab Control called 'tabs' it has 12 Tab Pages each named something different, e.g. aa, bb,tt, gg

each tab page contains a number of text boxes.  I have a command button on the form (not on any of the tab pages) which when clicked, i would like to clear all the text boxes on all the tab pages, so far i have this:

Dim ctl As Object

        For Each ctl In Me.aa.Controls
            If TypeOf ctl Is TextBox Then
                ctl.text = ""
            End If
        Next

This clears all the textboxes on the first tab called aa.
To clear the rest of the textboxes on the other tabs i could have to have this code again but with a different tab page name e.g. bb

Is there a way to use another outer for loop e.g.:

for each TABPAGE in TABCONTROL
       name = TABPAGE.name

        For Each ctl In Me.name.Controls
            If TypeOf ctl Is TextBox Then
                ctl.text = ""
            End If
        Next
next


something along those lines?  However it dosnt work and i cant figure a way out?

Gary
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial