现在正在做个系统,但是想在登录窗口输入密码时,限制密码输入错误的次数,不知道该怎么用代码实现?能否提供一下代码。

解决方案 »

  1.   

    在login的form中加个pirvate的变量,如果输入了错误密码的次数。
    如果登陆错误后,把这个变量加1,然后再判断这个数是否大于3,如果大于3强行退出。
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      ntime:Integer;
    implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    beginif Edit1.Text<>'ydk' then
    begin
      inc(ntime);
      if ntime>3 then Application.Terminate
      else
      ShowMessage('第'+inttostr(ntime)+'次');
      
    end;end;end.
      

  3.   

    呵呵
    听说一个学生要去面试
    招聘单位问有作品吗
    他说有
    “登陆系统”
    更有强者
    有个学生不知道做了点什么东东
    结果没数据库,招聘单位问怎么没数据库
    答“不会拷”
    不过俺也经历过更丢人的事,毕业两年后去面试程序员,关键是想学习
    结果通过了,要求不严格的
    人家让我做东西,人家问我为什么不用DBEDIT,俺说不好用,其实不知道什么叫DBEDIT
    不过呢,不会就要努力学习
    呵呵