Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing TextBoxes within GroupBoxes

Status
Not open for further replies.

Ragnarox

Programmer
Oct 2, 2003
141
US
Hi all,

I am trying to clear all the textboxes on my form. The problem that I am having is that the textboxes are inside of GroupBoxes and the following code only sees the GroupBoxes.

Code:
Dim ctl As Control

For Each ctl In Controls
   If TypeOf ctl Is TextBox Then
       ctl.Text = ""
   End If
   [green]'test line to see what controls I am hitting[/green]
   MessageBox.Show(ctl.Name)
Next

Do I need to have a seperate variable to access the controls within the GroupBoxes and therefore have a nested loop or is there just something that I am missing?


Any help, as always, is greatly appreciated.

Brian
 
Hi all,

Just figured it out. Made new Control var and had a loop within the loop look for controls within the control.


Brian
 
Brian,

A recursive sub is usually better for this. There are plenty of examples of recursion here.

Craig

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top