I have found this code for using control array in VB.net, but this only works when I place text boxes on form, whereas in my case within tab control i have created group boxes and within group boxes there are a number of text boxes which i have used for control array. Please help me out regarding the problem.
Code is here:

For Each ctl In frm.Controls
            startOfIndex = ctl.Name.ToLower.IndexOf(controlName.ToLower & separator)
            If startOfIndex = 0 Then
                strSuffix = ctl.Name.Substring(controlName.Length)
                'Check that the suffix is an integer (index of the array)
                If IsInteger(strSuffix) Then
                    If Val(strSuffix) > maxIndex Then maxIndex = _
                        Val(strSuffix) 'Find the highest indexed Element
                End If
            End If
        Next ctl

I downloaded this code from following link:

Assuming that you want to do something similar with all of the textboxes within a groupbox, try the following code:

Dim ctl As Windows.Forms.Control

For Each ctl In Me.GroupBox2.Controls
    If ctl.GetType.ToString = "System.Windows.Forms.TextBox" Then
        ctl.Text = "splunge"
    End If

I believe in some cases you may have to cast ctl to System.Windows.Forms.TextBox before you access the properties.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.