Clearing Textboxes on form GroupBox


Hi,
I have 10 texboxes placed in  a groupBox on a windowsform. I would like to clearall the texboxes  .
Is there a way to specify which textboxes in the 10 present  I dont want to clear looping thru the textboxes on the form
like if txtname then avoid clearing it
Thx in advance
sainavya1215Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ptakjaCommented:
You can put the textboxes into an array & then check the names to determine if you want to clear them or not:

Dim atxtboxes as TextBox() = {Textbox1, Textbox2, Textbox3, TextBox4, TextBox5, TextBox6, Textbox7, Textbox8, Textbox9, Textbox10}

Dim ii As Integer
For ii = 0 to atxtboxes.Length-1
     Select Case atxtboxes(ii).Name
          Case "TextBox1", "TextBox3"       'Clear all textboxes in array EXCEPT Textbox1 & Textbox3
          Case Else
               atxtboxes(ii).Text = String.Empty
      End Select
Next
0
sainavya1215Author Commented:
Dim atxtboxes as TextBox() = {Textbox1, Textbox2, Textbox3, TextBox4, TextBox5, TextBox6, Textbox7, Textbox8, Textbox9, Textbox10}

Is this an array..... ?? Instead of mentioning all the textboxes in array cant we do it by looping thru textbox controls on form
0
sainavya1215Author Commented:
MoreOver these textboxes as mentioned are placed in Groupbox
0
ptakjaCommented:
Sure you can. Here's what that code would look like:


For Each ctl As Control In GroupBox1.Controls
    If TypeOf(ctl) Is TextBox Then
        ctl.Text = String.Empty
    End If
Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.