如一个edit中 有不确定的以逗号分隔的字符串
1,2,33,23,aa,432,3e,er4,ee,fdff,dfdf利用程序获取所有以逗号分隔的记录和记录的总个数。
如上例
读取为
1
2
33
23
aa
432
3e
er4
ee
fdff
dfdf总数:11eidt中的逗号个数不确定

解决方案 »

  1.   


    var
      list:TStringList;
    begin
      list := TStringList.Create;
      try
        list.Delimiter := ',';
        list.DelimitedText := '1,2,33,23,aa,432,3e,er4,ee,fdff,dfdf';
        ShowMessage(list.Text);
      finally
        list.Free;
      end;
    end;
      

  2.   

    var
      ss: tstringlist;
    begin
      ss := tstringlist.create;
      ss.text := stringreplace(edit1.text, ',', #10, [rfReplaceAll]);
      showmessage(ss.text);
      ss.free;
    end;
      

  3.   

    通常用1楼方式……list.Count就是总数
      

  4.   

    TStringList 是最经典的用法
      

  5.   

    咱现在的是习惯是:
    var
      list: TStringList;
    begin
      list := TStringList.Create;
      try
        list.LineBreak := ',';
        list.Text := ...
        ...
      finally
        list.Free;
      end;
    end;
      

  6.   

    你们把循环给人家写出来啊
    for i := 0 to list.count - 1 do
    begin
      showmessage(list[i]);
    end;
      

  7.   


    这样的话ss.Count就可能不准确了哦