var tt:tstringlist; i:integer; begin tt:=tstringlist.create; tt.LoadFromFile('m:\xx.txt'); for i:=0 to tt.count-1 do begin label.caption:=tt[i]; end; tt[2]:='fffdsfdsfdfdsfdf'; //对第二行修改 tt.savetofile('m:\xx.txt'); tt.free; end;
用几个label来显示 定义n个label for i:=0 to tt.count-1 do begin Tlabel(Findcomponent('label'+inttostr(i))).caption:=tt[i]; end;keke,抢点分
tt:tstringlist;
i:integer;
begin
tt:=tstringlist.create;
tt.LoadFromFile('m:\xx.txt');
for i:=0 to tt.count-1 do
begin
label.caption:=tt[i];
end;
tt[2]:='fffdsfdsfdfdsfdf'; //对第二行修改
tt.savetofile('m:\xx.txt');
tt.free;
end;
定义n个label
for i:=0 to tt.count-1 do
begin
Tlabel(Findcomponent('label'+inttostr(i))).caption:=tt[i];
end;keke,抢点分
TextFile中怎么定位到第n行
应该是可以的,Readln不就是指针在移动吗?
然后
memo1.line[i] 就可以取得第i 行的全部字符然后 可以进行你的操作
但是文件比较大时读取时间过长 很不好
Seek对于文本文件不能用