Hello HackForums
Gonna share something useful (I hope so)
Got tired of doing this one:
TextBox1.Text = ""
TextBox2.Text = ""
So someone help me and give me this simple snippet. I haven't found something like this here.
I hope it helps you 👍
Gonna share something useful (I hope so)
Got tired of doing this one:
TextBox1.Text = ""
TextBox2.Text = ""
So someone help me and give me this simple snippet. I haven't found something like this here.
Code
Public Sub ResetSomething(frm As Form)
Dim ctrl As Control
For Each ctrl In frm.Controls
'Clearing Textbox
'Checking if the Control is a TextBox
If TypeOf ctrl Is TextBox Then
ctrl.Text = ""
'All TextBox will be empty.
End If
'You can also reset a control inside a panel or groupbox
If TypeOf ctrl Is GroupBox Then
Dim cntrl As Control
For Each cntrl In ctrl.Controls
If TypeOf cntrl Is TextBox Then
'Just doing the same things
cntrl.Text = ""
End If
Next cntrl
End If
Next ctrl
End SubI hope it helps you 👍



