Well, you can't use arrays in switch statements like that... The name of an array is a pointer to the first element of the array, and you can't have a pointer in a switch statement. I know you can use integers and characters and probably other primitive data types in switch statements.... Now I'm not sure exactly how your StateArray relates to your five Shape objects, but it looks like you just want a list of numbers to use in the switch statement. Maybe you could try something like this:
Code:
void __fastcall TForm1::NextButtonClick(TObject *Sender)
{
int state = 1; // Somehow set the value to 1, 2, 3, 4, or 5
switch(state)
{
case 1 : Shape5->Brush->Color = clRed; break;
case 2 : Shape4->Brush->Color = clRed; break;
case 3 : Shape3->Brush->Color = clRed; break;
case 4 : Shape2->Brush->Color = clRed; break;
case 5 : Shape1->Brush->Color = clRed; break;
}
}
Or perhaps state could be an index to your StateArray, and the switch statement could be:
switch (StateArray[state])
Is that what you're trying to do?
EDIT: I must type slow, looks like two others beat me to it