-
I have four TextBox arrays on a form. e.g. Text1(0) through (5), Text2(0) through (5), etc.
What's the best way to Clear these?
I'm currently using a For/Next loop but, being arrays, I'm wondering if something like Erase might work. I get an "Expected Array" error when trying to use Erase.
Thanks,
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
-
Private Sub ClearTextBoxes()
Dim ctl as Control
For Each ctl in Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
End Sub
...that'll clear out every textbox on the active form regardless of it's name...
-
Just beware of the way listed above that you will clear out all text boxes on the form. Other wise it is fine.
If you're using this code on the same form ok, but if you use it in a module pass the form thru to the module and you can then use it in various places.