checkbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have six checkboxes that I need to reset with a button. Is there a way to
reset all checkbox. checked = false with an array or loop.

I am still learning
Thanks
 
freddy said:
I have six checkboxes that I need to reset with a button. Is there a way to
reset all checkbox. checked = false with an array or loop.

Sure you can.
Dim arrChecks() As CheckBox
arrChecks(0) = Me.CheckBox1
arrChecks(1) = Me.CheckBox2
...
...

For Each chk As CheckBox In arrChecks
chk.Checked = False
Next chk

Or

If you want to uncheck all check boxes on your form or within a frame or
panel, you could do this:

' Parent is your form, panel or frame
For Each Ctrl In Parent.Controls
If TypeOf Ctrl is CheckBox Then
DirectCast(Ctrl, CheckBox).Checked = False
End If
Next Ctrl
I am still learning
I'm learning too :)


hope that helps..
Imran.
 
freddy said:
I get checkbox in a type and cannot be used as e=an expression

Strange - works for me. Can you post the code you have? And also point to
where you are getting the error.


Imran.
 
freddy said:
I have six checkboxes that I need to reset with a button. Is there a way to
reset all checkbox. checked = false with an array or loop.

I am still learning
Thanks

dim cb as checkbox
for each cb in me.controls
cb.checked=false
next

This will reset all checkboxes on your form. Ofcourse you could group
them on a panel or something, then you'd replace the me.controls with
panel1.controls or something to that effect.

Rinze van Huizen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top