var acomponent:componenttype;
for i:=1 to strtoint(edit1.text) do
begin
acomponent.create(self);
with acomponent do
begin
parent:=.....
name:=edit2.text;
......
end;
end;
根据Liuchuanbao兄的答案,我给个小小的补丁
var acomponent:array[1..30] of Tbutton{以按钮为例};// 生成一个以上的空件最好用ARRAY[]数组声明{其中30由您自己在编程时考虑决定}
comcount: integer;
procedure TForm1.Button1Click(Sender: TObject);
begin
comcount:=strtoint(edit1.text);
for i:=1 to comcountdo
begin
acomponent[comcount].create(self);
with acomponent[comcount]do
begin
parent:=.....
name:=edit2.text;
......
end;
end;
end;