Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Refresh label with a for loop Posted by ictteacher on 7 Feb 2009 at 10:40 AM
Hi.

I've just registered and this being my first time on a forum like this, I am in need of some desperate help. I have written an assignment for my students but having no experience of using Delphi before I have had to spend hours learning how to use it. I do have relevant experience Pascal so it makes it easier.

The problem is that the program should ask the user for a password and if entered incorrectly three times, the "logon" button show be inactive forcing the user to close the program. If the user types in the correct password then a simple calculator should be displayed. I can do this but I cannot force the program to:-

1) Display the value for the number of attempts in a read only label

2) Force the program to make the "logon" button inactive after the user has typed an incorrect password three times.

I have displayed the code for the "logon" button below. Any help would be much appreciated! Thanks in advance!

procedure Tnnn.btnlogonClick(Sender: TObject);
var
  attempt:Integer;
  flag:Boolean;
const
  password= 'qwerty';
begin
  attempt:=0;
  flag:=False;
  Repeat
    if edtpassword.Text = password then
      begin
        flag:=True;
        lblpassword.Hide;
        edtpassword.Hide;
        btnlogon.Hide;
        lblnumberofattempts.Hide;
        edtattempt.Hide;
        lbl1stvalue.Show;
        lbl2ndvalue.Show;
        lblanswer.Show;
        sed1stvalue.Show ;
        sed2ndvalue.Show;
        btnAdd.Show;
        btnsubtract.Show;
        btnmultiply.Show;
        btndivide.Show;
        edtAnswer.Show;
        bmbreset.Show;
      end
    else
      begin
        Inc(attempt);
        ShowMessage(IntToStr(attempt));
        {Inc(attempt);
        edtattempt.text:=IntToStr(attempt);
        MessageBox(0, 'Password Incorrect!','Integer Calculator', +mb_ICONINFORMATION);}
      end;
  until (attempt<4) or (flag=true);
end;




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.