Clearing all radio buttons on a form
Hopefully this is something quick.
I have a form with 4 group boxes. 2 of them have text boxes. I found how to clear them quick enough in past postings to this forum.
The basic idea is that you have to loop through the controls to find the group box then loop to find the text boxes, like this:
VB Code:
For Each c1 As Control In Me.Controls
If TypeOf c1 Is GroupBox Then
For Each c2 As Control In c1.Controls
If TypeOf c2 Is TextBox Then
c2.Text = Nothing
End If
Next
End If
Next
So I tried to add another IF statement to uncheck the radio boxes. Something like:
VB Code:
If TypeOf c2 is RadioButton Then
c2.Checked = False
End If
but that doesn't work. Checked is not a parameter that you can change for a control.
I only had 8 radio buttons, so I just did :
VB Code:
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton5.Checked = False
RadioButton6.Checked = False
RadioButton7.Checked = False
RadioButton8.Checked = False
But is there a better way?