Skip to content

Instantly share code, notes, and snippets.

@devCcori
Created November 19, 2021 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devCcori/5e0866015fa96b18562a2578999f491a to your computer and use it in GitHub Desktop.
Save devCcori/5e0866015fa96b18562a2578999f491a to your computer and use it in GitHub Desktop.
Function to reset all Controls in a form VB.NET 5.0
Private Sub resetAllControls(ByVal container As Control)
For Each ctrl As Control In container.Controls
If TypeOf ctrl Is RadioButton Then
DirectCast(ctrl, RadioButton).Checked = False
ElseIf TypeOf ctrl Is TextBox Then
DirectCast(ctrl, TextBox).Clear()
End If
If ctrl.Controls.Count > 0 Then
resetAllControls(ctrl)
End If
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment