PDA

Click to See Complete Forum and Search --> : Clearing TextBox arrays ????


Al Smith
Jan 16th, 2000, 04:07 AM
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:asmith3914@aol.com
asmith@spxateg.com">asmith3914@aol.com
asmith@spxateg.com</A>

Jan 16th, 2000, 01:29 PM
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...

Maartin
Jan 16th, 2000, 03:07 PM
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.