首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

读入txt文档里面的信息解决办法

2012-02-21 
读入txt文档里面的信息各位专家高手,请教一个问题:如何把txt文本里面的信息分段读入到字符串里面,原文本中

读入txt文档里面的信息
各位专家高手,请教一个问题:如何把txt文本里面的信息分段读入到字符串里面,原文本中没两个“&&”后面的内容为一个字段???

例如:

原文本为:&&张三&&18&&男&&北京

希望在memo显示出:

姓名:张三

年龄:18

性别:男

住址:北京

谢谢各位了!!!


[解决办法]
var
list:tstringlist;
oldstr:string;
begin
oldstr:= ':&&张三&&18&&男&&北京 ';
list:=TStringList.Create;
ExtractStrings([ '&& '],[],PAnsiChar(oldstr),List);
memo1.clear;
for i:=0 to list.count-1 do
begin
memo1.lines.add(list[i]);
end;
[解决办法]
看我的答案能不能帮你
http://community.csdn.net/Expert/topic/5482/5482017.xml?temp=.1966669
[解决办法]
打印
用这个试试,用Delphi的Demos里面的一段代码修改的,没有运行过
Screen.Cursor := crHourGlass; { <-- nice detail }
try
Printer.BeginDoc; { <-- start printer job }
try
{ now print some text on printer.canvas }
With Printer.Canvas do
begin
Font.Name:= '宋体 ';
Font.Size:=9; { <-- set the font size }
Font.Style:=[];
TextOut(0,0,Memo1.Text); { <-- print some text }
end;

Printer.EndDoc; { <-- end job and print !! }
except
on Exception do { just in case an error happens... }
Begin
Printer.Abort;
Printer.EndDoc;
Raise; { <-- raise up the exception !!! }
end;
end;
finally
Screen.Cursor:=crDefault; { <-- restore cursor }
end;

热点排行