文本文件不大的话。function delete_line(line:string;filename); var s:strings; count:integer; begin s:=tstringlist.create; s.loadfrom(filename); count:=0; while count<s.count-1 do if s[count]<>line then inc(count); if count=s.count-1 then s[count]:=' ' else 把后面的覆盖前面的。 s.savefile(filename); s.free. 老兄这么点分??????????
var str1:tstrings i:integer; begin str1:=tstringlist.creat; str1.LoadFromFile('c:\xxx.txt'); for i:=1 to str1.count do begin if str1[i]:='1234567' then str1[i]:=''; end; str1.savetofile('c:\xxx.txt'); end;
var i:integer; begin memo1.Lines.LoadFromFile('c:\ts.txt'); for i:=0 to memo1.Lines.Count-1 do if memo1.Lines.Strings[i] ='12345' then begin memo1.Lines.Delete(i); break; end; memo1.Lines.SaveToFile('c:\ts.txt'); 注意:需要一个tmemo组件
var
s:strings;
count:integer;
begin
s:=tstringlist.create;
s.loadfrom(filename);
count:=0;
while count<s.count-1 do
if s[count]<>line then inc(count);
if count=s.count-1 then s[count]:=' ' else
把后面的覆盖前面的。
s.savefile(filename);
s.free.
老兄这么点分??????????
str1:tstrings
i:integer;
begin
str1:=tstringlist.creat;
str1.LoadFromFile('c:\xxx.txt');
for i:=1 to str1.count do
begin
if str1[i]:='1234567' then
str1[i]:='';
end;
str1.savetofile('c:\xxx.txt');
end;
i:integer;
begin
memo1.Lines.LoadFromFile('c:\ts.txt');
for i:=0 to memo1.Lines.Count-1 do
if memo1.Lines.Strings[i] ='12345' then
begin
memo1.Lines.Delete(i);
break;
end;
memo1.Lines.SaveToFile('c:\ts.txt'); 注意:需要一个tmemo组件