我的代码需要给你整理一下,跟当前无关的给你去掉,并且给你测试好,你不要这么急<br><br>var<br> tpStr, msg: string;<br> Count, Count2,i,tpInt: integer;<br>begin<br> tpStr:='123456,23456,3456,456,56,6,77,88,99';<br> Count:=0;<br> while pos(',',tpStr) > 0 do<br> begin<br> inc(Count);<br> tpStr:=copy(tpStr,pos(',',tpStr)+1,length(tpStr)-pos(',',tpStr));<br> end;<br> if length(tpStr) > 0 then<br> inc(Count);<br> ShowMessage(Format('共有%d个分字符串!',[Count]));<br><br> tpStr:='123456,23456,3456,456,56,6,77,88,99';<br> Count2:=0;<br> for i:=0 to Count-1 do<br> begin<br> if pos(',',tpStr) > 0 then<br> begin<br> tpInt:=strToInt(copy(tpstr,1,pos(',',tpStr)-1));<br> tpStr:=copy(tpStr,Pos(',',tpStr)+1,length(tpStr)-pos(',',tpStr));<br> end<br> else<br> tpInt:=strToInt(tpStr);<br> Inc(Count2);<br> msg:=msg+InttoStr(tpInt);<br> if Count2 <> 3 then<br> msg:=msg+'---';<br> if ((i+1) mod 3 = 0) then<br> begin<br> ShowMessage(msg);<br> Count2:=0;<br> msg:='';<br> end;<br> end;<br>end;