关于动态创建和释放控件的问题
if drt<>50 then
   begin
   y:=1;
   while y<=drt do
    begin    if Assigned(medit[y]) then
      begin
      
      medit[y].Free;      end;
     if Assigned(mlabel[y]) then
      begin      mlabel[y].free;      end;
     if Assigned(mmemo[y]) then
      begin      mmemo[y].Free;
      end;    y:=y+1;
    end;
   end;
   i:=1;
   y:=1;
   x:=1;
   z:=1;
   e:=1;
   lt:=20;
   l:=10;
   t:=20;
   while i<100 do    begin     if pos(BN,ar2[i,1])<>0 then
      begin      mlabel[y]:=TLabel.Create(GroupBox1);
      mlabel[y].Parent:=GroupBox1;
      mlabel[y].Font.Size:=9;
      mlabel[y].AutoSize:=true;
      mlabel[y].AutoSize:=false;
      mlabel[y].Width:=mlabel[y].Width+80;
      mlabel[y].Left:=l;
      mlabel[y].Top:=t;
      mlabel[y].Caption:=copy(ar2[i,2],pos('.',ar2[i,2])+1,strlen(pchar(ar2[i,2]))-pos('.',ar2[i,2]))+':';      lt:=lt+mlabel[y].Height+15;      table1.Active:=true;      if (table1.FieldByName(copy(ar2[i,1],pos('.',ar2[i,1])+1,strlen(pchar(ar2[i,1]))-pos('.',ar2[i,1]))).size<=20) then
      begin      medit[z]:=TEdit.Create(groupbox1);
      medit[z].Parent:=groupbox1;
      medit[z].Font.Size:=10;
      medit[z].Height:=mlabel[1].Height+5;
      medit[z].Width:=175;
      medit[z].left:=l+mlabel[y].Width;
      medit[z].Top:=t;
      medit[z].text:='';      t:=t+medit[z].Height+5;
      z:=z+1;      end;
      edits:=z-1;
      if (table1.FieldByName(copy(ar2[i,1],pos('.',ar2[i,1])+1,strlen(pchar(ar2[i,1]))-pos('.',ar2[i,1]))).size>20) then
      begin      mmemo[x]:=TMemo.Create(groupbox1);
      mmemo[x].Parent:=groupbox1;
      mmemo[x].Font.Size:=10;
      mmemo[x].ScrollBars:=ssBoth;
      mmemo[x].Width:=medit[1].width;
      mmemo[x].left:=l+mlabel[y].Width;
      mmemo[x].Top:=t;
      mmemo[x].text:='';
      t:=t+mmemo[x].Height+5;
      x:=x+1;
      end;
      memos:=x-1;
      
      if t>groupbox1.Height-100 then
      begin
      v:=t;
      l:=l+strtoint(floattostr(round(groupbox1.Width/2)));
      t:=20;
      end;      drt:=y;
      y:=y+1;
      end;为什么在释放时,次数多了就报错!!!???      i:=i+1;
     end;