and then execute the statement. On the network to collect some information, and then write a line to read TXT text file program, here and share with you. Procedure TForm1.Button1Click (Sender: TObject); Var The definition of textfile data type in fi:TextFile; //system unit A1:string;...
//将帐号信息写入文本文件函数 procedure TForm1.WriteUserToText(user:String; pass:String); var txt:TextFile; begin //先判断一下文件是否存在, 不存在时就创建它 if not FileExists('C:\p.txt') then begin Assignfile(txt,'c:\p.txt'); //指定文件路径 rewrite(txt); //创建并打开一个新文件(或...
Onthenetworktocollectsomeinformation,andthenwritea linetoreadTXTtextfileprogram,hereandsharewithyou. ProcedureTForm1.Button1Click(Sender:TObject); Var Thedefinitionoftextfiledatatypeinfi:TextFile;//system unit A1:string; I:integer; Strsql:string; ...
(first write file) Procedure TForm1.Button2Click (Sender: TObject); Var S: string; Begin AssignFile (F, FileName); Reset (F); / / open read only Readln (F, s); / / read ShowMessage (s); / / display: the first line Readln (F, s); / / continue to read ShowMessage (s); ...
content[i]);finallyclosefile(txtfile);end;end;使用时很简单,比如你要把Memo1的内容保存到D:\1.txt就这样调用:WriteTextFile('D:\1.txt',Memo1.lines);如果文件不存在它将创建,存在将写到尾部保存时,先将本次内容用临时串存储,然后用memo1.lines.loadfromfile,再memo1.lines.text+临时串...
stu.sName:=edt2.Text; Write(f,stu);finallyCloseFile(f);end;end;//记录类型文件 读procedureTForm1.btn3Click(Sender: TObject);typestudent=recordsNo:string[10]; sName:string[10];end;varf:Fileofstudent; stu:student; isize:Integer;beginAssignFile(f,'a.dat');tryifnotFileExists('a.dat')the...
原型:procedure ReadLn([ var F: Text; ] V1 [, V2, ...,Vn ]); V:文本文件变量。 V1……V2:用于存储读取的文本。 注意:在Delphi中,ReadLn过程用于读取文本文件的一行文本,并跳至该文本文件的下一行。 1.9、Write过程 作用:用于向一个文本文件写入数据。
Memo1.Lines.LoadFromFile ( TextFileName ) ; 这样在TMemo上所做的一切修改当调用Memo部件的SaveToFile方法后都会反映到文件中去。 1.2 记录文件 记录文件是一种操作更为灵活的文件类型。它允许同时为读和写打开,而且由于记录文件中每条记录的长度固定,所以可随机存取。
procedure TForm1.Button1Click(Sender: TObject);var s:TStringList; i,j:Integer; str1,str2:string;begin OpenDialog1.Execute; s:=TStringList.Create; s.Text:=Memo1.Text; //先给s值, str1:='插入值'; //我这里在有#号的位置的前面写上“插入值” str2:=s.Tex...
1,关联文件:AssignFile(pMyFile,'c:\ttt.csv'); 2,打开文件:Reset(pMyFile); 3,读取一行:Readln(pMyFile,pStr); 4,关闭文件:CloseFile(pMyFile); 示例: procedureTForm1.Button1Click(Sender:TObject); var pMyFile:textfile; pStr:string; begin ifOpenDialog1.Executethenbegin Assignfile(pMy...