Public Sub ClearTextBoxes(ByVal f As Form)
Dim meuForm As Type = f.GetType() Dim campos As Reflection.FieldInfo() = meuForm.GetFields(Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
For Each campo As Reflection.FieldInfo In campos If campo.FieldType.Name.ToLower = "textbox" Then Dim t As TextBox = DirectCast(campo.GetValue(f), TextBox) t.Text = "" End If Next
End Sub Call this function and pass the form name. NOTE: LIKE THIS YOU CAN CLEAR ALL CONTROLS USING A SWITCH CASE |