Click here to Skip to main content
13,293,474 members (58,442 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 29 Sep 2011

Clear All textboxes text in VB

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


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


About the Author

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

You may also be interested in...

Comments and Discussions

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

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

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

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