for i:=0 to 4 do a[i]:=TEdit(FindComponent('Edit' + IntToStr(i))).Text
var I:integer; begin for I:=0 to ComponentCount - 1 do IF ( Components[I] is TEdit) then (Components[I] as TEdit).Text:='' end;
1:首先為a[]數組分配足夠的空間; 2:賦值 var I,J: integer; begin J := 1; for I:=0 to ComponentCount - 1 do IF ( Components[I] is TEdit) then begin a[J] := (Components[I] as TEdit).Text; Inc(J); end; end;
a[i]:=TEdit(FindComponent('Edit' + IntToStr(i))).Text
begin
for I:=0 to ComponentCount - 1 do
IF ( Components[I] is TEdit) then (Components[I] as TEdit).Text:=''
end;
2:賦值
var I,J: integer;
begin
J := 1;
for I:=0 to ComponentCount - 1 do
IF ( Components[I] is TEdit) then
begin
a[J] := (Components[I] as TEdit).Text;
Inc(J);
end;
end;