question about checkboxes

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I have about ten checkboxes in a group box and there are about five
different types of group boxes on a form.

Why will this not work?

//
For Each c As CheckBox In gbAGD1.Controls
If c.Checked = True Then agFlag = True
Next
\\

I get a cast error.

What I want to do is instead of writing a line for each checkbox, just
iterate through the collection and see if one is checked.

Thanks for the information.

Brad
 
Brad said:
I have about ten checkboxes in a group box and there are about five
different types of group boxes on a form.

Why will this not work?

//
For Each c As CheckBox In gbAGD1.Controls
If c.Checked = True Then agFlag = True
Next
\\

I get a cast error.

\\\
For Each c As Control In Foo.Controls
If TypeOf c Is CheckBox Then
If DirectCast(c, CheckBox).Checked Then
Flag = True
End If
End If
Next c
///
 
Back
Top