uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,InvokeRegistry, DB, DBClient, ExtCtrls;type
TLoginDlg = class(TForm)
Label1: TLabel;
Label2: TLabel;
btnOK: TButton;
btnCancle: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure btnOKClick(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
class function VerifyAccount:Boolean;
class function Execute:Boolean;
end;var
LoginDlg: TLoginDlg;
implementation{$R *.dfm}
class function TLoginDlg.Execute:Boolean;
begin
with LoginDlg.Create(nil)do
try
Result :=ShowModal=mrOK;
finally
Free;
end;
end;class function TLoginDlg.VerifyAccount:Boolean;
var
TextFilevar:TextFile;
sUserName,sPassword,sLine:String;
begin
Result :=False;
AssignFile(TextFileVar,'F:\lianxi\user.txt');
Reset(TextFilevar);
while not Eof(TextFilevar)do
begin
ReadLn(TextFileVar,sLine);
sUserName :=Copy(sLine, 0, Pos('=', sLine)-1);
sPassword :=Copy(sLine,Pos('=',sLine)+1,MaxInt);
//账号不区分大小写,密码区分大小写
if SameText(sUserName, Edit1.Text) and (sPassword =Edit2.Text) then
begin
ModalResult :=mrOk;
Break;
end;
end;
CloseFile(TextFileVar);
Result := ModalResult = mrOk;
end;
procedure TLoginDlg.btnOKClick(Sender: TObject);
begin
if not VerifyAccount then
ShowMessage('账号或密码错误,请重新输入');
end;end.
[Error] Unit1.pas(57): Instance variable 'Edit1' inaccessible here
[Error] Unit1.pas(57): Instance variable 'Edit2' inaccessible here
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,InvokeRegistry, DB, DBClient, ExtCtrls;type
TLoginDlg = class(TForm)
Label1: TLabel;
Label2: TLabel;
btnOK: TButton;
btnCancle: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure btnOKClick(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
class function VerifyAccount:Boolean;
class function Execute:Boolean;
end;var
LoginDlg: TLoginDlg;
implementation{$R *.dfm}
class function TLoginDlg.Execute:Boolean;
begin
with LoginDlg.Create(nil)do
try
Result :=ShowModal=mrOK;
finally
Free;
end;
end;class function TLoginDlg.VerifyAccount:Boolean;
var
TextFilevar:TextFile;
sUserName,sPassword,sLine:String;
begin
Result :=False;
AssignFile(TextFileVar,'F:\lianxi\user.txt');
Reset(TextFilevar);
while not Eof(TextFilevar)do
begin
ReadLn(TextFileVar,sLine);
sUserName :=Copy(sLine, 0, Pos('=', sLine)-1);
sPassword :=Copy(sLine,Pos('=',sLine)+1,MaxInt);
//账号不区分大小写,密码区分大小写
if SameText(sUserName, Edit1.Text) and (sPassword =Edit2.Text) then
begin
ModalResult :=mrOk;
Break;
end;
end;
CloseFile(TextFileVar);
Result := ModalResult = mrOk;
end;
procedure TLoginDlg.btnOKClick(Sender: TObject);
begin
if not VerifyAccount then
ShowMessage('账号或密码错误,请重新输入');
end;end.
[Error] Unit1.pas(57): Instance variable 'Edit1' inaccessible here
[Error] Unit1.pas(57): Instance variable 'Edit2' inaccessible here
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货