Clear 10 or more textboxes in just one click.
Introduction
In this article I am going to show how to clear 10 or more textboxes in just one click. My example in here I'm just going to show up just 10 textboxes.
Creating the Form
We need to create a form with 10 textboxes and 3 buttons.
Textboxes names:
Textbox1,TextBox2,...,TextBox10
Button Names:
btnClearLeft,bntClearRight,btnClear

Clear Left
On btnClearLeft Click Event, put this one
For Each ctrl As Control In Me.Controls 'For each control on the form.
If TypeOf ctrl Is TextBox Then 'See if the type is a Textbox.
Dim idx As Integer = CInt(ctrl.Name.Replace("TextBox", ""))
If idx >= 1 And idx <= 5 Then
CType(ctrl, TextBox).Text = ""
End If
End If
Next
Result:

Clear Right
On the btnClearRight Click event, put this one
For Each ctrl As Control In Me.Controls 'For each control on the form.
If TypeOf ctrl Is TextBox Then 'See if the type is a Textbox.
Dim idx As Integer = CInt(ctrl.Name.Replace("TextBox", ""))
If idx >= 6 And idx <= 10 Then
CType(ctrl, TextBox).Text = ""
End If
End If
Next
Result:

Clear 1,2,3,9 and 10
On the btnClear event, put this one
For Each ctrl As Control In Me.Controls 'For each control on the form.
If TypeOf ctrl Is TextBox Then 'See if the type is a Textbox.
Dim idx As Integer = CInt(ctrl.Name.Replace("TextBox", ""))
If idx < 4 Or idx > 8 Then
CType(ctrl, TextBox).Text = ""
End If
End If
Next
Result:

Conclusion
This article maybe useful if we have so many textboxes and we need to clear the text on it in just a single click.