Delete a text box


Is it possibe to delete a textbox from a form programmtaically?

I was looking for something like


but could not find it.

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.

Fernando SotoRetiredCommented:
Try this


yes, it's : textbox1.dispose

let me know if you have any problems.
Fernando SotoRetiredCommented:
Yes sr101880 that is what I told yo_daz_uk to do.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

sorry, your comment wasn't on my screen when I hit submit.  No hard feelings. :-)  yo_daz_uk , Please disregard my comment.
Fernando SotoRetiredCommented:
No problem sr101880 and you have a great day. ;=)
If you want to remove the textbox from the form but to use its properties anyway for any reason.
=> This line is valid if the textbox is placed on the form.
If it is placed on a panel or groupbox or any other container use that container's controls array

But if you want to delete the textbox not only from the form but also from the memory, then use the method that FernandoSoto and sr101880 propesed.
yo_daz_ukAuthor Commented:
Thanks its in a hast table is the also a way to empty a hash table ?
Fernando SotoRetiredCommented:
Hi yo_daz_uk;

This code will delete all the TextBox's in the HashTable and delete all the elements in the HashTable.

        ' ht is the HashTable with TextBox.s in its array
        For Each obj As Object In ht
            Dim tb As TextBox
            ' Cast objects in the HashTable to TextBox's
            tb = CType(obj.Value, TextBox)
            ' Delete the TextBox's

        ' Delete all the elements in the HashTable


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
yo_daz_ukAuthor Commented:
Thanks fernado, i knew it was something basic i just couldnt find the answer!
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.