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:

6 Years
Discussion Span
Last Post by Reverend Jim

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.

Edited by Reverend Jim: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.