Do you have a form that has a lot of textboxes?

do you want to clear all those textboxes for example when there is a new?

this is the old scenario:

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""

etc…………
this is my idea:

Sub ClearForm(ByVal frm_name As Form)
Dim Contrl As Control
For Each Contrl In frm_name.Controls
If (TypeOf Contrl Is TextBox) Then Contrl.Text = ""
Next Contrl
End Sub

this is my friend samir ibrahim‘s idea, compatible with “.net framework 3.5 +”

For Each _Ctrl As Control In Me.Controls.OfType(Of TextBox)()
_Ctrl.Text = ""
Next

The second idea is more optimized with same result.

Of course my idea is cooler because i made it :mrgreen:

you just need to pass the form name to the function & it will clear the form for you, this will save your fingers extensive redundant typing :mrgreen::mrgreen::mrgreen::mrgreen::mrgreen: