0

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..:)

2
Contributors
2
Replies
18
Views
4 Years
Discussion Span
Last Post by Gobroski
0

What have you got so far? A switch is a case of, Delphi uses dot notation instead of the arrow, and := for assignments.

Edited by pritaeas

1

nailed it!!!

  for x := 0 to 5 do
  begin
    i := random(6)+1;
    case i of
      1 : TLMDSpeedButton(Components[x]).Color := clRed;
      2 : TLMDSpeedButton(Components[x]).Color := clSilver;
      3 : TLMDSpeedButton(Components[x]).Color := clBlue;
      4 : TLMDSpeedButton(Components[x]).Color := clYellow;
      5 : TLMDSpeedButton(Components[x]).Color := clGreen;
      6 : TLMDSpeedButton(Components[x]).Color := clFuchsia;
    else;
  end;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.