EASY BUTTON QUESTION!!

I want my users to be able to click and activate a button only 5 or so times before it becomes disabled.  How can I achieve this, in the quickes manner?

Thanks
Tony
aj85Asked:
Who is Participating?
 
BigMadDrongoConnect With a Mentor Commented:
have a property in your form declaration for the number of times the button is clicked.  Set this to 0 at the start.  In the OnClick event of the button, increment this counter.  If the counter is 5 then disable.  E.G.

TMyForm = class(TForm)
  btn1: TButton;
private
  count: integer;
end;

procedure TMyForm.btn1Click(Sender: TObject);
begin
  inc(count);
  if count = 5 then
    btn1.Enabled := false;
end;

initialization
  count := 0;

BigMadDrongo
0
 
aj85Author Commented:
Thanks for the quick answer, it work very well!

Tony
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.