Clearing text in TextBoxes

  • Thread starter Thread starter CG Rosén
  • Start date Start date
C

CG Rosén

Good Day Group,

Have a UserForm with abt 70 Text and ComboBoxes.
They are named TextBox1 etc but not in consecutive order. Is there a way
with a short code to clear the text
in these boxes to avoid using:

TextBox1 = "" etc. abt 70 times?

(The boxes are grouped in 5 Frames)

Thanks in advance.

Brgds

CG Rosén
 
How about a For Next Loop? You can loop thru the collection making sure it's
a textbox and clear it.
 
Good Day Group,

Have a UserForm with abt 70 Text and ComboBoxes.
They are named TextBox1 etc but not in consecutive order. Is there a way
with a short code to clear the text
in these boxes to avoid using:

TextBox1 = "" etc. abt 70 times?

(The boxes are grouped in 5 Frames)

Thanks in advance.

Brgds

CG Rosén
For Each Ctl In Me.Controls
Select Case LCase(TypeName(Ctl))
Case "textbox"
Ctl.Value = vbNullString
End Select
Next
--
Met vriendelijke groeten / Mit freundlichen Grüßen / With kind
regards/Avec mes meilleures salutations
BBert

April 20, 1986
Celtics (135) - Bulls (131)
Larry Bird: "God disguised as Michael Jordan"
 
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is msforms.TextBox Then
ctl.Text = ""
End If
Next ctl

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top