文件名称:delphi中如何读取有逗号分割符数据
文件大小:167KB
文件格式:RAR
更新时间:2012-07-21 13:49:12
delphi读取逗号分割符数据
function GetDelimiteredStringN(Astring:String;Dlmter:Char;nPos:integer):string; var sList:TStringList; begin Result:=''; sList:=TStringList.Create; sList.Text:=StringReplace(Astring,Dlmter,#13#10,[rfReplaceAll]); if (nPos>0) and (sList.Count>=nPos) then Result:=sList[nPos-1]; end; procedure TForm1.Button1Click(Sender: TObject); var str : TStringList; begin str := TStringList.Create; str.Delimiter := ','; str.DelimitedText :=memo1.text; edit1.text:=str.Text; //showmessage(str.Text); end; procedure TForm1.Button2Click(Sender: TObject); begin edit1.Text:=(GetDelimiteredStringN(memo1.text,',',1));//第3个*后的字符. edit2.Text:=(GetDelimiteredStringN(memo1.text,',',2));//第3个*后的字符. edit3.Text:=(GetDelimiteredStringN(memo1.text,',',3));//第3个*后的字符. end;
【文件预览】:
Project1.dof
Unit1.dcu
Project1.exe
Unit1.dfm
Project1.cfg
Project1.dpr
Unit1.~dfm
Unit1.pas
Project1.res
Unit1.ddp
Unit1.~pas