This works in C++ Builder:
int chcolor;
for(int d, d < 5, d++);
{
String name = "d" + IntToStr(i+1);
TLMDSpeedButton* button = dynamic_cast<TLMDSpeedButton*>(this->FindComponent(name));
chcolor = random(6)+1;
switch (chcolor)
{
case 1:
button->Color = clRed;
break;
case 2:
button->Color = clSilver;
break;
case 3:
button->Color = clBlue;
break;
case 4:
button->Color = clGreen;
break;
case 5:
button->Color = clYellow;
break;
case 6:
button->Color = clFuchsia;
break;
default:;
}
}
Thank you for your help..:)