Click here to Skip to main content
Click here to Skip to main content

Tagged as

Clear All textboxes text in VB

, 2 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Clear All textboxes text in VB
If you want to clear all the textboxes in VB, then instead of setting property of each by calling the name we can set it by using the below code. In this, we will read all the controls and if the control is a textbox, then we set it to blank.

Dim X As Control
For Each X In Me.Controls
    If TypeOf X Is TextBox Then
        X = ""
    End If
Next X

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mithun Thakur From NICE Computers
Software Developer (Senior) NICE Computers
India India
No Biography provided
Follow on   Twitter

Comments and Discussions

 
GeneralRecursion is an elegant solution, I'll vote 5. Pinmemberalxmedina3-Oct-11 11:47 
GeneralWrite the above code in c# PinmemberAjayAnirudhSingh29-Sep-11 19:56 
GeneralRe: public void ClearTextBoxes(Control control) { ... PinmemberMithun Thakur From NICE Computers30-Sep-11 1:07 
GeneralReason for my vote of 3 Controls can form a hierarchy as in ... PinmvpLuc Pattyn29-Sep-11 3:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 2 Oct 2011
Article Copyright 2011 by Mithun Thakur From NICE Computers
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid