delphi 处理以逗号分隔的长字符串  
官方Delphi 学习QQ群: 682628230(三千人)\n
频道

delphi 处理以逗号分隔的长字符串


方法1:

procedure Str_Tools;
var
    TmpList:TStringList;
    IIndex:Integer;
    MUSVOL:String;
begin
    MUSVOL:='0,2,4,6,8,10';
    TmpList:=TStringList.Create;
    try
        while Pos(',',MUSVOL)>0 do
        begin
            IIndex:=Pos(',',MUSVOL);
            TmpList.Add(Copy(MUSVOL,1,IIndex-1));
            Delete(MUSVOL,1,IIndex);
        end;
        TmpList.Add(MUSVOL);
        showmessage(TmpList.Strings[1]);
   finally
        TmpList.free;
   end;
end;


方法2:
procedure Str_Tools2;
var
    I:integer;
    bol:Boolean;
    MUSLIST:Tstringlist;
    Dsp_MusicVol:array [0..6]of integer;
begin
    try
    MUSLIST:=Tstringlist.Create;
MUSLIST.CommaText:='1,3,5,7,9,11';
        for i:=0 to 6 do
        begin
           if (MUSLIST.Count>=i-1) then  Dsp_MusicVol[i]:=strtoint(MUSLIST[i]);
           showmessage(Dsp_MusicVol[i]);
        end;
        
    finally
        MUSLIST.free;
    end;
 
end;


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.088890075683594 seconds