I have a form that lists nine children as labels and has three checkboxes for each child denoting whether they ate breakfast, lunch and/or snack.
If they ate any meal, I am logging that to a CSV file. I need to know how to loop through each child and see if they ate any meals.
Basically, child1 gets logged if chkbox1 or chkbox2 or chkbox3 is checked. If no checkbox is checked, the child is not logged. Then on to the next child.
I don't need help with the logging, just the loop through the checkboxes.
Thanks.
If you name them to be - chkChild1Breakfast, chkChild1Lunch, chkChild1Snack
-
chkChild2Breakfast, chkChild2Lunch, chkChild2Snack
-
etc.
then you can do a For Next loop very easily. - Dim i As Integer
-
Dim chkBreakfast As Checkbox
-
Dim chkLunch As Checkbox
-
Dim chkSnack As Checkbox
-
-
For i = 1 To 9
-
chkBreakfast = CType(Me.Controls("chkChild" & i.ToString() & "Breakfast", Checkbox)
-
chkLunch = CType(Me.Controls("chkChild" & i.ToString() & "Lunch", Checkbox)
-
chkSnack = CType(Me.Controls("chkChild" & i.ToString() & "Snack", Checkbox)
-
-
If chkBreakfast.Checked Or chkLunch.Checked Or chkSnack.Checked Then
-
'At least one meal was eaten
-
-
Else
-
'No meal was eaten
-
-
End If
-
Next
3 1571
If you name them to be - chkChild1Breakfast, chkChild1Lunch, chkChild1Snack
-
chkChild2Breakfast, chkChild2Lunch, chkChild2Snack
-
etc.
then you can do a For Next loop very easily. - Dim i As Integer
-
Dim chkBreakfast As Checkbox
-
Dim chkLunch As Checkbox
-
Dim chkSnack As Checkbox
-
-
For i = 1 To 9
-
chkBreakfast = CType(Me.Controls("chkChild" & i.ToString() & "Breakfast", Checkbox)
-
chkLunch = CType(Me.Controls("chkChild" & i.ToString() & "Lunch", Checkbox)
-
chkSnack = CType(Me.Controls("chkChild" & i.ToString() & "Snack", Checkbox)
-
-
If chkBreakfast.Checked Or chkLunch.Checked Or chkSnack.Checked Then
-
'At least one meal was eaten
-
-
Else
-
'No meal was eaten
-
-
End If
-
Next
Other than adding a paren before the ", Checkbox", it worked as expected. Thank you very much!
Oops. My bad. For the sake of anyone else trying to do something similar, here is the corrected code: - Dim i As Integer
-
Dim chkBreakfast As Checkbox
-
Dim chkLunch As Checkbox
-
Dim chkSnack As Checkbox
-
-
For i = 1 To 9
-
chkBreakfast = CType(Me.Controls("chkChild" & i.ToString() & "Breakfast"), Checkbox)
-
chkLunch = CType(Me.Controls("chkChild" & i.ToString() & "Lunch"), Checkbox)
-
chkSnack = CType(Me.Controls("chkChild" & i.ToString() & "Snack"), Checkbox)
-
-
If chkBreakfast.Checked Or chkLunch.Checked Or chkSnack.Checked Then
-
'At least one meal was eaten
-
-
Else
-
'No meal was eaten
-
-
End If
-
Next
Glad it helped.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: DSmith |
last post by:
I have a quality control database containing data for samples pulled
every four hours (several years worth of data). What I need to do is
find the maximum value for a field for each eight hour...
|
by: Amal Ismail |
last post by:
hello
this is the third time i inquire aboutthe same
thing and none answer me !! .. hope to find help here
i'm using ASP.NET Mobile web application using c#
And i'm facing a problem , i use...
|
by: Edward Mitchell |
last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a
format of Time. The controls are all embedded in dialogs. I created the
controls by dragging the DateTime picker from...
|
by: BrianDH |
last post by:
Hi
I have a form with multi-tabs, and on each tab I have a one combo that has
the same values.
I populate all 3 combo with the same one datacall/dataset
My problem is: when I make a value...
|
by: ashok76 |
last post by:
Hi
I've a DataGridView and where has column 0 is a DataGridViewComboBoxColumn Whenever I selected that cell then the drop down list not appeared on single click event hence I need to click again...
|
by: ameshkin |
last post by:
What I want to do is very simple, but I'm pretty new at PHP and its a
little hard for me.
I have one page, where there are a rows of checkboxes. A button
selects all checkboxes, and then...
|
by: David T. Ashley |
last post by:
I have Red Hat Enterprise Linux 4.
I was just reading up about UTC and leap seconds.
Is it true on my system that the Unix time may skip up or down by one second
at midnight when there is a...
|
by: Sebarry |
last post by:
Hi,
I've put together a little test page to create checkboxes each time a button is clicked. The check button is created and should be appended to the form, but when the post is submitted the...
|
by: tdahsu |
last post by:
I have twenty-five checkboxes I need to create (don't ask):
self.checkbox1 = ...
self.checkbox2 = ...
..
..
..
self.checkbox25 = ...
Right now, my code has 25 lines in it, one for each...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |