我做的一个小程序中我点一下确定 生成6个数字
分别放在 6个Label中
现在我像要吧着6个Label.caption的值存到文本文件中
但是要求他们在一行 数与数之间留 一个空格 就像这样 10 12 13 14 15 17
这样要怎么弄啊
向高手请教

解决方案 »

  1.   


    var
      i: integer;
      f: textfile;
      tmp: string;
    begin
      tmp := '';
      for i:=1 to 6 do
      begin
        if (FindComponent(Format('Label%d',[i]))<>nil) and (FindComponent(Format('Label%d',[i])) is TLabel) then
          tmp := tmp+TLabel(FindComponent(Format('Label%d',[i]))).Caption+' ';
      end;
      tmp := LeftStr(tmp,Length(tmp)-1);  //去掉最后一个多余空格
      assignfile(f,'c:\aa.txt');
      rewrite(f);
      write(f,tmp);
      closeFile(f);
      

  2.   

    LSZJvar
      i: integer;
      f: textfile;
      tmp: string;
    begin
      tmp := '';
      for i:=1 to 6 do
      begin
        if (FindComponent(Format('Label%d',[i]))<>nil) and (FindComponent(Format('Label%d',[i])) is TLabel) then
          tmp := tmp+TLabel(FindComponent(Format('Label%d',[i]))).Caption+' ';
      end;
      tmp := LeftStr(tmp,Length(tmp)-1);  //去掉最后一个多余空格
      assignfile(f,'c:\aa.txt');
      rewrite(f);
      write(f,tmp);
      closeFile(f);