下面是我现在的代码,现在能实现了从TXT文件从读取信息,我是根据Edit1.Text中字符串中的时间来读取的,如果Edit1.Text中字符串中的时间是2007-05-08 ,我TXT文件中最后的时间是2007-05-08 那么我在MEMO中显示的也就是2007-05-08 这天纪录的内容。如果我Edit1.Text中字符串中的时间是2007-05-01,那么 MEMO中显示的也就是2007-05-01 到2007-05-08 这几天的内容。 请问怎么样写才能只显示Edit1.Text中字符串中的时间对应的内容,其他时间纪录的内容不显示var
s1,s2,S,ALLText:string;
F:textfile;
nPosBegin,nPosEnd:integer;
begin Edit1.Text:=ShellTreeView1.Path;
s1:=ExtractFileName(Edit1.Text);
nPosBegin:=Pos(',',s1);
nPosEnd:=LastDelimiter(',',s1);
s2:=Copy(s1,nPosBegin+1,nPosEnd-nPosBegin-1);
// showmessage(s2); Assignfile(F,'E:\operview参数备份\Readme.txt');
reset(F);
while not EOF (F) do begin
readln(F,S);
if CompareStr(S,s2)=0 then
while not EOF (F) do begin
readln(F,S);
ALLText:=ALLText + S+#13#10;
end;
Memo1.Clear;
memo1.Text:=ALLText;
end;
closefile(F);
end;
s1,s2,S,ALLText:string;
F:textfile;
nPosBegin,nPosEnd:integer;
begin Edit1.Text:=ShellTreeView1.Path;
s1:=ExtractFileName(Edit1.Text);
nPosBegin:=Pos(',',s1);
nPosEnd:=LastDelimiter(',',s1);
s2:=Copy(s1,nPosBegin+1,nPosEnd-nPosBegin-1);
// showmessage(s2); Assignfile(F,'E:\operview参数备份\Readme.txt');
reset(F);
while not EOF (F) do begin
readln(F,S);
if CompareStr(S,s2)=0 then
while not EOF (F) do begin
readln(F,S);
ALLText:=ALLText + S+#13#10;
end;
Memo1.Clear;
memo1.Text:=ALLText;
end;
closefile(F);
end;
2007-04-30 16-16-32dfssdfd
155354522007-04-30 16-21-38121212
WW
受到2007-05-08 08-17-54雁荡山
雁荡山
雁荡山
AStringList.LoadFromFile(...);
for I:=0 to AStringList.Count-1 do begin
if Pos(AStringList[I], YourStr)=1 then
...
end;