Control Arrays in VBA???


Posted by Ron on June 04, 2001 6:49 AM

I have a couple userforms that each have over 20 textboxes on each one (named txtE1, txtE2, etc.).

Is it possible to create a control array as in VB or is there another way to quickly clear these text boxes when a user clicks a clear button on the form.

Thanks for any help. Ron



Posted by Tuc on June 04, 2001 7:54 AM


Ron,
Try thiscode. I think it will do what you want.

Private Sub CommandButton1_Click()
Dim objControl As Control
Dim intCounter As Integer

For intCounter = 0 To Me.Controls.Count - 1

Set objControl = Me.Controls(intCounter)
If TypeOf objControl Is MSForms.TextBox Then
objControl.Object.Text = ""
End If
Next intCounter

Set objControl = Nothing

End Sub

Tuc