str  :array[1..max] of string;s:='123 4567 891051'i:=1;
str[1]:='';
for j:=1 to length(s) do
  begin
    if s[j]<>' ' then str[i]:=str[i]+s[j]
    else begin inc(i); str[i]:=''; end;
  end;

解决方案 »

  1.   

    Pos只能找到第一个空格!不能用。
      

  2.   

    var
      Des,Sou :string;
      P   :PChar;
    begin
      Sou := '12345 645 00';
      P := PChar(Sou);
      repeat
        if P^<>' ' then Des :=Des + P^;
        Inc(P);
      until P^=#0;
    end;
      

  3.   

    pos函数+Copy组合当然可以做了,只不过稍微麻烦点。
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
        s:string;
        i,j:integer;
        Temp:array of string;
    begin
        s:='123  4567   891051';
        j:=length(s);
        setlength(temp,j);
        j:=0;
        while pos(' ',s)>0 do
        begin
            i:=pos(' ',s);
            Temp[j]:=Copy(s,1,i-1);
            j:=j+1;
            s:=RightStr(s,length(s)-i);
            s:=trim(s);
        end;
        temp[j]:=s;
        for i:=0 to j do
        begin
            showmessage(temp[i]);
        end;
    end;
    无论你有多少个空格相连都能搞定,结果存在数组temp中
      

  5.   

    其实用TStringList是最简单的。
    Var
      ss : TStrings;
    Begin
      ss := TStringList.Create;
      ss.CommaText := '123 4567 891051';
      //  ss.Strings[0] is '123', [1] is '4567' ...
      ss.Free;
    End;虽然CommaText是为','分隔串设计的,但也支持空格。
      

  6.   

    看来,DELPHI还有很多好东东可以挖呀!:)