unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
Label1: TLabel;
edtAccount: TEdit;
Label2: TLabel;
edtPassword: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
function VerifyAccount:Boolean; //声明位置不对?
private
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.dfm}procedure TForm2.Button2Click(Sender: TObject);
begin
close;
end;procedure TForm2.Button1Click(Sender: TObject);
begin
if not VerifyAccount then
ShowMessage('账号或密码错误,请重新输入。');
end;function VerifyAccount:Boolean;
var
TextFileVar:TextFile;
sUserName,sPassword,sLine:string;
begin
Result:=False;
AssignFile(TextFileVar,'powder.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,edtAccount.Text)and(sPassword=edtPassword.Text)then //这是57行
begin
ModalResult:=mrOK; //这是59行,ModalResult是什么? 与Result不一样?
Break;
end;
end;
CloseFile(TextFileVar);
Result:=ModalResult=mrOK;
end;end.
[Error] Unit2.pas(57): Undeclared identifier: 'edtAccount'
[Error] Unit2.pas(57): ')' expected but identifier 'Text' found
[Error] Unit2.pas(59): Undeclared identifier: 'ModalResult'
[Warning] Unit2.pas(64): Comparing signed and unsigned types - widened both operands
[Error] Unit2.pas(19): Unsatisfied forward or external declaration: 'TForm2.VerifyAccount'
[Fatal Error] Project1.dpr(7): Could not compile used unit 'Unit2.pas'
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
Label1: TLabel;
edtAccount: TEdit;
Label2: TLabel;
edtPassword: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
function VerifyAccount:Boolean; //声明位置不对?
private
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.dfm}procedure TForm2.Button2Click(Sender: TObject);
begin
close;
end;procedure TForm2.Button1Click(Sender: TObject);
begin
if not VerifyAccount then
ShowMessage('账号或密码错误,请重新输入。');
end;function VerifyAccount:Boolean;
var
TextFileVar:TextFile;
sUserName,sPassword,sLine:string;
begin
Result:=False;
AssignFile(TextFileVar,'powder.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,edtAccount.Text)and(sPassword=edtPassword.Text)then //这是57行
begin
ModalResult:=mrOK; //这是59行,ModalResult是什么? 与Result不一样?
Break;
end;
end;
CloseFile(TextFileVar);
Result:=ModalResult=mrOK;
end;end.
[Error] Unit2.pas(57): Undeclared identifier: 'edtAccount'
[Error] Unit2.pas(57): ')' expected but identifier 'Text' found
[Error] Unit2.pas(59): Undeclared identifier: 'ModalResult'
[Warning] Unit2.pas(64): Comparing signed and unsigned types - widened both operands
[Error] Unit2.pas(19): Unsatisfied forward or external declaration: 'TForm2.VerifyAccount'
[Fatal Error] Project1.dpr(7): Could not compile used unit 'Unit2.pas'
解决方案 »
- 在RichEdit中(有全角,半角,中,英文等字符)如何用pos()函数正确取出我想要的位置值?
- 快速监控DIRECT窗口图形变化
- 歡迎加入Delphi聖地QQ群(19234671)
- delphi+access 简单的查询,为何要出错?高分相送!
- 如何添加到鼠标右键中
- 求救,明晨交货,关于文件关联,高分!
- 为什么我的RXLIB2。7控件包在DELPHI6下安装不上去
- 如何在DATABASE DESKTOP 中使用函数?
- 地摊上的D版Delphi6简体中文版是不是真的中文版?
- 急急急,请问有没有人用过createfont给个实例,谢谢!
- image控件显示图片,如何设置按钮对图片进行放大缩小?
- 请教高手,关于飞信软件。
begin
//dothing.
end;
要么VerifyAccount这个函数放到TForm2里,要么就在edtAccount、edtPassword和ModalResult前都加上“Form2.”(就是变成Form2.edtAccount和Form2.edtPassword、Form2.ModalResult,虽然不推荐这样,但也能让你编译过,运行也没什么问题)