Quote Originally Posted by stateofidleness View Post
vb Code:
  1. Dim Count as Integer = 1
  2. Dim currentIndex as Integer = 0
  3. For Count = 1 to 31 'You need to go to 31 because indexes are 0-based
  4.      DirectCast(Me.Controls("XB" & Count.ToString & "TextBox"), TextBox).Text = T(currentIndex.ToString)
  5.      currentIndex+=1
  6. Next

See if that works. The syntax on the DirectCast may be off a bit, but should be very close. I'm unable to test at the moment
Just as a side note here, you don't need to cast a control type to a textbox type just to access its .text property. The text property is inherited from the base control class anyway. You only need to cast when you need to access something specific to the given class, that is not inherited from the base class you already have an instance of.

Also, 1 to 31 is 31 iterations, not 30... 0 to 29 or 1 to 30 is 30 iterations of a loop.

I would code this out something like this:

Code:
        For Count As Integer = 1 To 30
            Me.Controls(String.Format("XB{0}TextBox", Count.ToString)).Text = T(Count - 1)
        Next
where I am assuming T is some 30 element array of strings?