Robert said:
In VB, I could have a textbox, and have an array of 10, examples text1(0),
text1(1) etc.
VB 'Proper's "Control Arrays" are Dead and Gone.
Instead, you can now create Arrays of Controls.
Start with the ten individual TextBoxes, then add them all into an
array, usually in Form_Load.
Dim m_tbs as TextBox() = Nothing
Private Sub Form_Load( ... ) _
Handles Mybase.Load
m_tbs = New TextBox() { tb1, tb2, ..., tb10 }
End Sub
Then, at any point, you can loop through that array, doing whatever you
need to do.
For Each tb as TextBox in m_tbs
tb.Text = String.Empty ' say
Next
To handle events on [all] the TextBoxes, use multiple "Handles" clauses
on a single event handler and the sender argument to identify the
calling control, as in
Private sub TB_EnabledChanged( ... ) _
Handles tb1.EnabledChanged _
, tb2.EnabledChanged _
, ... _
, tb10.EnabledChanged
With DirectCast( sender, TextBox )
.BackColor = ...
End With
End Sub
If you're adding the TextBoxes dynamically, use the AddHandler statement
to "wire-up" the event handlers.
HTH,
Phill W.