[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Help with modifying sub routine...

I have this Sub that is in my class.  It clears controls that are associated with the designated form, however, it will not clear any controls that are contained in my Tabcontrol.  Here is my code:

Public Sub CLEARDATA(ByVal frm As ContainerControl)

        For Each newControl As Control In frm.Controls
            If TypeOf (newControl) Is TextBox Then
                newControl.Text = ""
            ElseIf TypeOf (newControl) Is ComboBox Then
                newControl.Text = ""
            ElseIf TypeOf (newControl) Is ContainerControl Then
                CLEARDATA(newControl)
            End If
        Next

    End Sub
0
vilusion
Asked:
vilusion
1 Solution
 
Brian CroweCommented:
try it this way

Public Sub CLEARDATA(ByVal collection As Control.ControlCollection)

            Try
                  For Each ctl As Control In collection
                        If ctl.Controls.Count > 0 Then
                              CLEARDATA(ctl.Controls)
                        End If
                        If TypeOf (ctl) Is TextBox Then
                              ctl.Text = ""
                        ElseIf TypeOf (ctl) Is ComboBox Then
                              CType(ctl, ComboBox).SelectedIndex = -1
                        End If
                  Next
            Catch ex As Exception
                  MessageBox.Show(ex.Message)
            End Try
      End Sub

an example usage would be...

CLEARDATA(me.controls)
0
 
vilusionAuthor Commented:
Worked great!  Thank you!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now