'create your Sub procedure named "clearall" with a parameters type as object. Public Sub clearall(ByVal form As Object) 'for each txt as control in form(object).control For Each txt As Control In form.Controls 'conditioning the txt as control by getting it's type. 'the type of txt as control must be textbox. If txt.GetType Is GetType(TextBox) Then 'if the object(textbox) is present. The result is, the textbox will be cleared. txt.Text = Nothing End If Next End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'confirming that the data will be clear 'call your Sub name. clearall(Me) End Sub