asked on
ASKER
Dim TBs As New Collection
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
TBs.Add ctl, ctl
End If
Next
End Sub
' An Example of How to Iterate over the TextBoxes:
Private Sub Foo()
Dim TB As Control
For Each TB In TBs
' ... do something with "TB" ...
Next TB
End Sub
ASKER
ASKER
ASKER
ASKER
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.
TRUSTED BY
If VB6 then not really.
If VB.Net then you can use LINQ to grab just the type you are interested in.
For both, you can use a Collection (VB6) or a List(VB.Net) and iterate just ONCE at Form Load so you can add the controls to that Collection/List. Then future operations can simply iterate the stored references instead of iterating over all controls.