关于delphi 编程的问题,在线等
来源:百度知道 编辑:UC知道 时间:2024/05/27 06:41:46
这是我编的登录程序,有一点小问题。解决输入3次错误信息以后,提示三次输入错误信息,清退出,可是不能实现,变量times在程序中没有起到计数作用,谁能帮我看看,我在线等。如果实现,再有加分。
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables;
type
Tloginfrm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Table1: TTable;
DataSource1: TDataSource;
Query1: TQuery;
Label3: TLabel;
ComboBox1: TComboBox;
Label11: TLabel;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
loginfrm: Tloginfrm;
implementation
uses main;
{$R *.dfm}
procedure Tloginfrm.Button2Click
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables;
type
Tloginfrm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Table1: TTable;
DataSource1: TDataSource;
Query1: TQuery;
Label3: TLabel;
ComboBox1: TComboBox;
Label11: TLabel;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
loginfrm: Tloginfrm;
implementation
uses main;
{$R *.dfm}
procedure Tloginfrm.Button2Click
1 :
showmessage('您已经三次输入错误信息,清退出!'); //不是程序最后一行的要加分号.
2 : // times:=0; 这句每一次都初始化都为0,当然没有效果
// 去掉原先把times定义,去掉 times:=0; 把times定义到private区
private
{ Private declarations }
times: Integer;//一般为FTimes
public
application.Terminate;改为halt;