Stack Exchange
for each looping textbox value
hello guys i have a problem with textbox
  For Each textBox As TextBox In GroupBox1.Controls.OfType(Of TextBox)().OrderBy(Function(b) b.TabIndex)
            textBox.Text = 1
            textBox.Text = 2

next
here i have 8 textbox like 
textbox1      textbox2
textbox3      textbox4
textbox5      textbox6
textbox7      textbox8

i want textbox1 = 1 and textbox2 = 2
textbox3 = 1 and textbox4 = 2 and son
i have try with 
 For Each aBox As Etcbox In GroupBox1.Controls.OfType(Of TextBox)().OrderBy(Function(b) b.TabIndex)
        aBox.Text = 1
        aBox.Text = 2

different name with textbox but i fail any help please am just trying and trying ...

If you already got them ordered the way you want, just increment a counter and assign the current counter value in your loop.

try calling the textbox by its name with directcast
For i = 1 to 8
       DirectCast(Me.Controls.Find("textbox" & i, True), Textbox).text = i
Next

or more properly check whether i is even or odd and assign accordingly
For i = 1 to 8
       if i mod 2 = 0 then
            DirectCast(Me.Controls.Find("textbox" & i, True), Textbox).text = "2" 
       else
            DirectCast(Me.Controls.Find("textbox" & i, True), Textbox).text = "1"
       end if
Next

I didn't test it, though.

Good catch on using Me.Controls.Find(<name>, True) to do a recursive lookup instead!

Me.Controls.Find(, True) is a big help and i totally forgot about mod ha ha ha i remember now when my master question me about mod series well thanks
