如何将一个Tstringlist的内容截取一部分,写到另一个Tstringlist中去?以及如何连接两个tstringlist。

解决方案 »

  1.   

    简单写一下
    a:tstringlist;
    b:tstringlist;
    c:tstringlist;
    a.CommaText:='1,2,3,4,5,6';
    现在的问题,如何把a中的1,2,3去掉,并把a 赋值给bc.commatext:='a,b,c';
    如何把a和c连接起形成一个tstringlist 象这样:c.commatext:='1,2,3,4,5,6,a,b,c'
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
        a:tstringlist;
        b:tstringlist;
        c:tstringlist;
        i:integer;
    begin
        a:=TStringList.Create;
        b:=TStringList.Create;    a.CommaText:='1,2,3,4,5,6';
        c:=TStringList.Create;    for i:=3 to a.Count-1  do
        begin
            b.Add(a.Strings[i]);
        end;
        c.commatext:='a,b,c';
        for i:=0 to a.Count-1 do
        begin
            c.Insert(i,a.strings[i]);
        end;
        showmessage(a.GetText);
        showmessage(b.gettext);
        showmessage(c.GetText);
    end;
      

  3.   

    TStringList.AddStrings===================
    procedure TForm1.FormCreate(Sender: TObject);var
      MyList: TStringList;
      Index: Integer;
    begin
      MyList := TStringList.Create;
      try
        MyList.Add('Animals');
        MyList.Add('Flowers');    MyList.Add('Cars');    MyList.Sort;   { Find will only work on sorted lists! }
        if MyList.Find('Flowers', Index) then
        begin
          ListBox1.Items.AddStrings(MyList);
          Label1.Caption := 'Flowers has an index value of ' + IntToStr(Index);
        end;
      finally
        MyList.Free;
      end;
    end;
      

  4.   

    先TStringList.Delete
    再TStringList.AddStrings