You could use FindComponent to find the appropriately named objects. FindComponent is a method of TComponent, which means that it will be available in your form. You could use code like the following:
type TMyForm = class(TForm) // lots of things go here private MyArray: array[0..6] of TLabel; // other stuff goes here
(I.e., declare your array inside the form. Get into your form's OnCreate event and put in the following code:
procedure Tyourformname.FormCreate(Sender: TObject);var iter: Integer;begin for iter := Low(MyArray) to High(MyArray) do MyArray[iter] := FindComponent('Label' + IntToStr(iter+1)) as TLabel;end;
That will fill your array up with the labels, which you can then use as you please. Of course, it's a bit shifty relying on a variable's name but whatever, it works. FindComponent returns the component with the given name, or nil if it isn't found (I believe). If you place the object on something (for example, a TPanel) then you could change the code to look like this: MyArray[iter] := Panel1.FindComponent{etc};
[edited by - Alimonster on July 9, 2002 8:25:32 AM][edited by - Alimonster on July 9, 2002 8:28:44 AM]