//说明,将S分开到List中。
procedure SplitString(const S: String; List: TStrings);
begin
  List.CommaText := S;
end;

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var t :array of string;  //数组
      r: string;   //要分割的字符串
      i: integer;begin
      i:=0;
      repeat
      t[i]:=copy(r,1,pos(';',r));
      r:= copy(r,pos(';',r)+1,length(r)-pos(';',r));
      until pos(';',r)=0;end;
      

  2.   

    SplitString VB中有,delphi中没有吧,我也想知道在哪里啊?
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    const
      s = 'abc;defg;higk;112213;';
    var
      StrList: TStringList;
    begin
      StrList := TStringList.Create;
      try
        StrList.Delimiter := ';';
        // 字符串已经以;为分割符分开
        StrList.DelimitedText := s;
        // 验证
        Memo1.Lines.Assign(StrList);
      finally
        FreeAndNil(StrList;);
      end;
    end;
      

  4.   

    sorry,写错一句
    FreeAndNil(StrList;);
    应该是
    FreeAndNil(StrList);
      

  5.   

    Tstringlist根本就没Delimiter属性
      

  6.   

    function ConnectionStringToList(ConnectionString:string):TStringList;
    var
      ResultList:TStringList;
      Str:string;begin
      ResultList:=TStringList.Create;
      ResultList.Clear;
      Str:=ConnectionString;
      while Pos(';',Str)>0 do begin
        ResultList.Add(Copy(Str,1,Pos(';',Str)-1));
        Str:=Copy(Str,Pos(';',Str)+1,Length(Str)-Pos(';',Str)+1);
      end;
      ResultList.Add(Str);
      Result:=ResultList;
    end;
      

  7.   

    TO: heartstill
    你用的Delphi版本是多少?我用Delphi 6是可以的
      

  8.   

    Edit1为要分割的串,子串存在ListBox中
    procedure TForm1.Button1Click(Sender: TObject);
    var
      P:Integer;
    begin
      P:=Pos(';',Edit1.Text);
      while P<>0 do
      begin
        ListBox1.Items.Add(Copy(Edit1.Text,1,P-1));
        Edit1.Text:=Copy(Edit1.Text,P+1,Length(Edit1.Text)-P);
        P:=Pos(';',Edit1.Text);
      end;
      if Edit1.Text<>'' then
        ListBox1.Items.Add(Edit1.Text);
    end;
      

  9.   

    ///分割一个字符串,其中分割的标志是ch
    用法:
    var str:tstrings;
    str:=SplitString(source,';');
    function SplitString(const source,ch:string):tstrings;function SplitString(const source,ch:string):tstrings;
    var
     temp:string;
     i:integer;
    begin
     result:=tstringlist.Create;
     temp:=source;
     i:=pos(ch,source);
     while i<>0 do
     begin
       result.Add(copy(temp,0,i-1));
       delete(temp,1,i);
       i:=pos(ch,temp);
     end;
     result.Add(temp);
    end;