Refresh label with a for loop - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Refresh label with a for loop

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!

[code]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;[/code]
Sign In or Register to comment.