I have a form that creates a row of checkboxes depending on the type of analysis the user wants to perform on the incoming file. I need to be able to determine if the checkbox is "checked" but I don't know how to do that when the controls are created at runtime.

So right now I have a loop going through all the controls on the form and selecting the appropriate case: for instance chkbox1, combobox1, etc. Now I can access the values of the control by using


but after that the only thing resemebling checked is .Text which wouldn't be accurate.

So my question is: how do you workaround the .Checked property of a checkbox when it is created at runtime?

You have to cast the items to the checkbox type in order to access its abilities.







If you have other controls, then you need to do a check before you cast:

For each ctrl as control in me.controls
if TypeOf(ctrl) is CheckBox then
'case and do work here
end if

Note: Aircoded.

Hope this helps.

Edited 6 Years Ago by Stevoni: n/a

Thank you. I just used the first one and it worked like a charm. In the future I'll use what you posted last to make it uniform.

This question has already been answered. Start a new discussion instead.