Shawn said:
I'm trying to go through a large number of logically named textboxes
using a loop and cannot figure out how short of explicitly referencing
every single one.
The days of being able to sensibly "get at" a Control based solely on
its /Name/ are long gone.
Generally speaking, having the Name of something isn't much use.
Having a /reference/ to the thing itself (through which, of course, you
can ask the object its Name) is much, /much/ better.
Create yourself an array of TextBoxes - or an ArrayList containing
TextBoxes or (VB'2005+) a List(Of TextBox) - containing the ones you
want to work with and loop through that, as in:
Private m_allTextBoxes as New List(Of TextBox)
Private Sub InitialiseFields()
m_allTextBoxes.Add( Me.TextBox1 )
. . .
m_allTextBoxes.Add( Me.TextBox<n> )
End Sub
''' <remarks type="rant" >
''' Is it just me that finds it annoying having "<" and ">" as part
''' of the language these days?
''' How are we supposed to mark non-syntactic bits of example code?
''' "<" and ">" are used for Attributes, "[" and "]" protect reserved
''' words and "(" and ")" have always been part and parcel of Basic...
''' Anyway ...
''' </remarks>
Private Sub Zap()
For Each tb As TextBox in m_allTextBoxes
tb.Text = String.Empty
Next
End Sub
HTH,
Phill W.