CheckBox

  • Thread starter Thread starter Carlo
  • Start date Start date
C

Carlo

Hi
I have checkboxes names chk1, chk2, chk3 etc
I need to count the number of checkboxes that have been ticked.
I was hoping to loop through the checkboxes by using:
for i = 1 to 40
if chk(i).checked = true then
total += 1
end
next

But the problem it seems is with chk(i). How do I loop through a
control name using a variable such as i?

Thanks
carlob1
 
Hi,

Debug.WriteLine(TotalChecked(Me))



Private Function TotalChecked(ByVal ctrl As Control) As Integer

Dim intTotal As Integer

For Each c As Control In ctrl.Controls

If TypeOf c Is CheckBox Then

intTotal += 1

Else

intTotal += TotalChecked(c)

End If

Next

Return intTotal

End Function



Ken
 
Hello,

Dim BillsItemChecked As Integer

For Each itm In ListViewPostBills.ListItems


If itm.Checked = True Then


BillsItemChecked = BillsItemChecked + 1

End If
Next itm


Thanks,


Warm Regards,

Ayaz Ahmed
Software Engineer & Web Developer
Creative Chaos (Pvt.) Ltd.
"Managing Your Digital Risk"
http://www.csquareonline.com
Karachi, Pakistan
Mobile +92 300 2280950
Office +92 21 455 2414
 
Back
Top