我在窗体建立时加入了一下代码:
procedure TForm1.FormCreate(Sender: TObject);
var strtmp,str:string;
        i:integer;
begin
    str:='239,233,32423,234,234,23424';
    for i:=1 to (length(str)) do
          begin
             if str[i]<>',' then
                  strtmp:=strtmp+str[i];
             if str[i]=','then
                      begin
                        combobox1.Items.Add(strtmp);
                        strtmp:='';
                      end;
         end;
end;
运行后达到你的要求,希望对你有帮助!!!!

解决方案 »

  1.   

    这是我写的,可以达到你要求
    procedure TForm1.ButSplitClick(Sender: TObject);
    var
      Inipos:integer;
      Endpos:integer;
      SourceLen:integer;
      FoundLen:integer;
      Sourcestr:string;
      Tempstr:string;
      Foundstr:string;
      Mystring:TStrings;
      Flag:Boolean;
    begin
      Flag:=false;
      Sourcestr:=Trim(Edit1.text);
      Foundstr:=Trim(Edit2.text);
      SourceLen:=Length(Sourcestr);
      FoundLen:=Length(Foundstr);
      Endpos:=pos(Foundstr,Sourcestr);
      inipos:=1;
      try
      Mystring:=TStringList.Create ;
      While Endpos<>0 do
         begin
            Tempstr:=Copy(Sourcestr,Inipos,(Endpos-Inipos));
            Mystring.Add (Tempstr);
            Sourcestr:=Copy(Sourcestr,Endpos+FoundLen,SourceLen-(Endpos+FoundLen-1));
            Endpos:=pos(Foundstr,Sourcestr);
            Flag:=true;
         end;
      if Flag then
         begin
           if Sourcestr<>'' then  
             listbox1.Items.Assign (Mystring);
         end;
       if Flag then
          messagedlg('Split Over,Now!',mtinformation,[mbok],0)
       else
          messagedlg('Not Split',mtinformation,[mbok],0);
      finally
          Mystring.Free ;
      end;
    end;
      

  2.   

    procedure Separate(const teststr:string;var str_result:tstringlist);
    var
      i:integer;
      temp:string;
    begin
      str_result.clear;
      temp:='';
      for i:=1 to length(teststr) do
      begin
        if teststr[i]<>',' then 
          temp:=temp+teststr[i]
        else
        begin
          str_result.add(temp);
          temp:='';
        end;
      end;
    end;
      

  3.   

    这样也行:
    var
      Str: string;
    begin
      Str:='123,343,2323';
      while Pos(',', Str) > 0 do
        Str[Pos(',', Str)] := Char(13);
      ComboBox1.Items.Text:=Str;
    end;
      

  4.   

    var aa,str:string;    
        i,j:integer;
    begin
    str:='239,233,32423,234,234,23424';    
    j:=1;
    for i:=1 to length(str) do
      begin
        if str[i]='+'then
          begin
            aa:=copy(str,j,i-j);
            combobox1.Items.Add(aa);                        
            j:=i+1;
          end
      else  if i=length(str) then
          begin
            aa:=copy(str,j,i-j+1);
            combobox1.Items.Add(aa);                        
          end;
      end;
    end; 
      

  5.   

    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;