Moin,
wenn man die Edits gleich am Anfang einsammelt, dann muss FindComponent() nicht so häufig aufgerufen werden:
Delphi-Quellcode:
uses
{ ... ,} Contnrs;
type
TDemoForm = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
procedure EditChange(Sender: TObject);
private
EditList: TObjectList;
EditSum: Double;
end;
{ ... }
procedure TDemoForm.FormCreate(Sender: TObject);
var
i: Integer;
begin
EditList := TObjectList.Create;
for i := 1 to 3 do
EditList.Add(FindComponent(Format('Edit%d', [i])));
end;
procedure TDemoForm.EditChange(Sender: TObject);
var
i: Integer;
dValue: Double;
begin
EditSum := 0;
for i := 0 to Pred(EditList.Count) do
if TryStrToFloat((EditList[i] as TEdit).Text, dValue) then
EditSum := EditSum + dValue;
// Caption := FloatToStr(EditSum);
end;
Grüße vom marabu