How to Clear Multiple TextBoxes VB.Net

0
811

How to Clear Multiple TextBoxes VB.Net

Clear Multiple TextBoxes VB.Net, If you are tired in coding for clearing and specifying the names of multiple TextBoxes on the Form, this tutorial will help you to clear multiple Textboxes without specifying the names of it. It will minimize your code and lessen your work. This method is to clear all the text in the TextBoxes in a certain Form.

this tutorial the best solution to the problem presented in some other site.

Steps on how to Clear Multiple TextBoxes VB.Net

Clear Multiple TextBoxes VB.Net
Clear Multiple TextBoxes VB.Net

Clear Multiple TextBoxes VB.NetSo, let’s begin:
Open the Visual Basic and create a new Windows Form Application.
After you finish creating a Windows Form Application, drag a Button and the TextBoxes on the Form as much as you can.

Double click the Button to fire the click event handler of it. Then, you have to put the code for clearing the Textboxes into it.

 

Add the pop-up message to notify you that the text has been successfully cleared.
[vbnet] ‘IT NOTIFY FIRST BEFORE CLEARING THE TEXT
MsgBox(“data cleared”)
[/vbnet] These are the full codes that you have created.
[vbnet] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
‘IT NOTIFY FIRST BEFORE CLEARING THE TEXT
MsgBox(“data cleared”)

‘LOOP THE CONTROL IN THE FORM OF CONTROLS
For Each txt As Control In Me.Controls
‘GETTING THE TYPE OF CONTROL WHICH IS A TEXTBOX
If txt.GetType Is GetType(TextBox) Then
‘CLEARING THE TEXTBOXES
txt.Text = Nothing
End If
Next
End Sub
[/vbnet] Now, press F5 on the keyboard to run your project.
You can also download the Complete Source Code  and run it on your computer.

 

If you find the tutorial useful, please help us grow by sharing this article with your friends. Thank You!

 

Summary

In summary, we have discus on how to clear multiple textbox in vb.net.

If you have any question or suggestion about this tutorial on how to clear multiple textbox in vb.net, please leave a comment below.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.