If you are using the IDE to create the labels then you have two choices:
Use your own array:
// in public or private
var Labels : array [1..2] of TLabel;
// in OnFormCreate or similar event
begin
Labels[1] := Label1;
Labels[2] := Label2;
end;
// somewhere else
var
lLabel : TLabel;
begin
for lLabel in Labels do lLabel.Caption := 'xyz';
end;
Use the TForm.Control array of the Form you're currently in:
var
I : integer;
lControl : TControl;
begin
for I := 0 to ControlCount-1 do
begin
lControl := Controls [I];
if lControl is TLabel then (lControl as TLabel).Caption := 'xxx';
end;
end;
If you are using the IDE to create the labels then you have two choices:
Use your own array:
Use the
TForm.Controlarray of the Form you're currently in: