var strTemp:string;
    strArray:array of integer;
    iLoop:integer;    strTemp := '1,2,2,23';
    iLoop := 0;
    While pos(',',strTemp) > 0 do
    begin
      strArray[iLoop] := strtoint(copy(strTemp,1,pos(',',strTemp)-1));
      Delete(strTemp,1,pos(',',strTemp));
      inc(iLoop);
    end;
    strArray[iLoop+1] := strtoint(strTemp);

解决方案 »

  1.   

    //同一个问题你要问几遍?
    type
      TArrayInteger = array of Integer;function Calc(mStr: string; var mArr: TArrayInteger): Boolean;
    var
      I: Integer;
    begin
      Result := False;
      if mStr = '' then Exit;
      with TStringList.Create do try
        Text := StringReplace(mStr, ',', #13#10, [rfReplaceAll]);
        SetLength(mArr, Count);
        for I := 0 to Count - 1 do mArr[I] := StrToIntDef(Strings[I], 0);
      finally
        Free;
      end;
      Result := True;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      vArr: TArrayInteger;
      I: Integer;
    begin
      Calc('10,223,3,3334,54,', vArr);
      for I := Low(vArr) to High(vArr) do
        ShowMessage(IntToStr(vArr[I]));
    end;
      

  2.   

    function StrSplit(Source,SplStr:String):TStrings;
      var
        s:String;
        i:Integer;
        ResList:TStrings;
      begin
        ResList:=TStringList.Create;
        s:=Source;
        i:=Pos(SplStr,S);
        while i<> 0 do
        begin
          ResList.Add(Copy(S,1,i-1));
          S:=Copy(S,i+1,Length(S)-i);      
          i:=Pos(SplStr,S);
        end;
        ResList.Add(S);    
        Result:=ResList;
      end;  然后你自己去调用StrToInt吧     ____     ____
         \ p \   / g /
          \ l \_/ n /
           \ a   o /
            \ i s /
             \ n /
              \_/