Looping through VCL components

Hello.
Can anyone tell me how to loop through a number of VCL components.
I am using RAD Studio XE7 C++
See code snippet:

// card 1
if(CheckBox1->Checked) ascii[3+15]='1';
if(CheckBox2->Checked) ascii[3+14]='1';
if(CheckBox3->Checked) ascii[3+13]='1';
if(CheckBox4->Checked) ascii[3+12]='1';
if(CheckBox5->Checked) ascii[3+11]='1';
if(CheckBox6->Checked) ascii[3+10]='1';
if(CheckBox7->Checked) ascii[3+9]='1';
if(CheckBox8->Checked) ascii[3+8]='1';
if(CheckBox9->Checked) ascii[3+7]='1';
if(CheckBox10->Checked) ascii[3+6]='1';
if(CheckBox11->Checked) ascii[3+5]='1';
if(CheckBox12->Checked) ascii[3+4]='1';
if(CheckBox13->Checked) ascii[3+3]='1';
if(CheckBox14->Checked) ascii[3+2]='1';
if(CheckBox15->Checked) ascii[3+1]='1';
if(CheckBox16->Checked) ascii[3+0]='1';

I want to loop through the CheckBoxes

Thanks,

Clint
TForm has an array called Components you can loop through - alternatively you can use FindComponent.

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Classes_TComponent_FindComponent.html
Thanks Thomas

Did it like this (had 128 to do in total!):

1
2
3
4
5
6
7
8
for (int i=0;i<16;i++)
{
TCheckBox *TempCheckBox = dynamic_cast<TCheckBox *>(Components[i+1]);
if (TempCheckBox)
	{
	if(TempCheckBox->Checked)	ascii[3+15-i]='1';
	}
}

Topic archived. No new replies allowed.