delphi程序问题
调试这个自己做的程序时出现以下错误提示,请高手帮忙看下是哪个地方出了问题,小弟刚学DELPHI,谢谢![Error]login.pas(24):Undeclaredide...
调试这个自己做的程序时出现以下错误提示,请高手帮忙看下是哪个地方出了问题,小弟刚学DELPHI,谢谢!
[Error] login.pas(24): Undeclared identifier: 'Tloginfrm'
[Error] login.pas(25): 'END' expected but 'VAR' found
[Error] login.pas(26): Statements not allowed in interface part
[Error] login.pas(29): Undeclared identifier: 'dbname'
[Error] login.pas(33): Undeclared identifier: 'ausername'
[Error] login.pas(36): Unterminated string
[Error] login.pas(37): Not enough actual parameters
[Error] login.pas(41): Undeclared identifier: 'apwd'
[Error] login.pas(58): Declaration expected but identifier 'public' found
[Error] login.pas(60): 'IMPLEMENTATION' expected but ';' found
[Error] login.pas(65): '.' expected but 'IMPLEMENTATION' found
[Error] login.pas(19): Unsatisfied forward or external declaration: 'Tloginfrm.BitBtn2Click'
[Error] login.pas(20): Unsatisfied forward or external declaration: 'Tloginfrm.FormShow'
[Error] login.pas(21): Unsatisfied forward or external declaration: 'Tloginfrm.BitBtn1Click'
[Hint] login.pas(24): Private symbol 'Tloginfrm' declared but never used
[Fatal Error] mjgl.dpr(8): Could not compile used
『代码如下:』
unit 'login.pas'unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, DB, DBTables,global,main;
type
Tloginfrm = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
GroupBox1: TGroupBox;
Label2: TLabel;
Label1: TLabel;
Image1: TImage;
namebox: TEdit;
pwdbox: TEdit;
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
function Tloginfrm.checkuser(ausername,apwd:string):integer;
var t:ttable;
begin
try
t:=TTable.create(nil);
t.databasename:=dbname;
t.tablename:='MSysUserList.DB';
t.open;
t.setkey;
t.fieldbyname('username').asstring:=ausername;
if not (t.gotokey) then
begin
messagedlg('用户名'+ausername+'错误!,mtError,[mbok],0);
result:=-1;
exit;
end
else
if t.FieldByName('pwd').AsString=apwd then
result:=t.fieldbyname('level').asinteger
else
begin
messagedlg('密码错误!',mtError,[mbok],0);
result:=-1;
exit;
end;
t.Close;
t.Free;
except
result:=-1;
messagedlg('连接数据库出错',mtError,[mbok],0);
end;
end;
{ Private declarations }
public
{ Public declarations }
end;
var
loginfrm: Tloginfrm;
implementation
uses global,main;
{$R *.dfm}
因为希望实现的功能是登录完以后才去判断用户名和密码,所以就放在implementation之前了
放在implementation之后就会提示一堆的变量没有定义了 展开
[Error] login.pas(24): Undeclared identifier: 'Tloginfrm'
[Error] login.pas(25): 'END' expected but 'VAR' found
[Error] login.pas(26): Statements not allowed in interface part
[Error] login.pas(29): Undeclared identifier: 'dbname'
[Error] login.pas(33): Undeclared identifier: 'ausername'
[Error] login.pas(36): Unterminated string
[Error] login.pas(37): Not enough actual parameters
[Error] login.pas(41): Undeclared identifier: 'apwd'
[Error] login.pas(58): Declaration expected but identifier 'public' found
[Error] login.pas(60): 'IMPLEMENTATION' expected but ';' found
[Error] login.pas(65): '.' expected but 'IMPLEMENTATION' found
[Error] login.pas(19): Unsatisfied forward or external declaration: 'Tloginfrm.BitBtn2Click'
[Error] login.pas(20): Unsatisfied forward or external declaration: 'Tloginfrm.FormShow'
[Error] login.pas(21): Unsatisfied forward or external declaration: 'Tloginfrm.BitBtn1Click'
[Hint] login.pas(24): Private symbol 'Tloginfrm' declared but never used
[Fatal Error] mjgl.dpr(8): Could not compile used
『代码如下:』
unit 'login.pas'unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, DB, DBTables,global,main;
type
Tloginfrm = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
GroupBox1: TGroupBox;
Label2: TLabel;
Label1: TLabel;
Image1: TImage;
namebox: TEdit;
pwdbox: TEdit;
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
function Tloginfrm.checkuser(ausername,apwd:string):integer;
var t:ttable;
begin
try
t:=TTable.create(nil);
t.databasename:=dbname;
t.tablename:='MSysUserList.DB';
t.open;
t.setkey;
t.fieldbyname('username').asstring:=ausername;
if not (t.gotokey) then
begin
messagedlg('用户名'+ausername+'错误!,mtError,[mbok],0);
result:=-1;
exit;
end
else
if t.FieldByName('pwd').AsString=apwd then
result:=t.fieldbyname('level').asinteger
else
begin
messagedlg('密码错误!',mtError,[mbok],0);
result:=-1;
exit;
end;
t.Close;
t.Free;
except
result:=-1;
messagedlg('连接数据库出错',mtError,[mbok],0);
end;
end;
{ Private declarations }
public
{ Public declarations }
end;
var
loginfrm: Tloginfrm;
implementation
uses global,main;
{$R *.dfm}
因为希望实现的功能是登录完以后才去判断用户名和密码,所以就放在implementation之前了
放在implementation之后就会提示一堆的变量没有定义了 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询