我的程序中的这个部分首先将客户广告到文本文件(在公共变量中声明)并将其保存到 texfile。onbutton1click 是搜索编辑框中的字符串并将相关客户详细信息返回到备忘录的过程。添加客户工作正常并添加到文本文件,但是当我搜索它时它不会返回任何到备忘录,只是备忘录标题,memo1。我有什么办法可以解决这个问题?抱歉,我是新手。
procedure TForm2.btnsaveClick(Sender: TObject);
begin
cusfname:= edit1.text ;
cuslname:= edit2.text;
adress:= edit3.text;
phone:= edit4.text;
password:= edit5.Text;
AssignFile(F, 'Data.txt');
append(F);
WriteLn(F, cusfname);
WriteLn(F, cuslname);
WriteLn(F, adress);
WriteLn(F, phone);
WriteLn(F, password);
CloseFile(F);
end;
procedure TForm2.Button1Click(Sender: TObject);
var
SearchFile : Textfile;
found: boolean;
search: string;
begin
search := edit1.text;
Assignfile(SearchFile, 'data.txt');
Reset(SearchFile);
found:= false;
repeat
found:= search = phone
until eof(searchfile) or found;
if found then
memo1.append(phone);
memo1.append(cusfname);
memo1.append(adress);
if not found then
showmessage('member not found');
end;