When you have a reset button on a vb form and you want that button to clear all of the text box fields, you have two options. Write code for each field to clear them or loop through each control on the form.
Here is an example of clearing each field individually:
Private Sub resetForm()
ServerName.text = ""
PortNumber.text = ""
and so on ....
End Sub
As you can see this give you complete control of each control individually. But if you have dozens of fields this can be a headache. Also, maintaining this becomes a hassle. Each time you add a control you have to update the resetform method.
Here is the loop through example:
Private Sub resetForm()
'Set an integer to loop through the controls
Dim x As Integer
' Set the loop for one less than the count because the fields start their index at 0
For x = 0 To Me.Controls.Count - 1
'if it is a text box then clear it
If TypeOf Me.Controls.Item(x) Is TextBox Then
Me.Controls.Item(x).Text = ""
End If
Next
End Sub
As you can see, this method never needs to be updated. You can add or remove controls to your form and the method with react accordingly.
You could also do the same thing for radio buttons, check boxes or any other editable field. You just need a case for each type of control.
Hope this helps someone.