Unit1.pas 783 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls;
  6. type
  7. TForm1 = class(TForm)
  8. btn1: TButton;
  9. btn2: TButton;
  10. procedure btn2Click(Sender: TObject);
  11. procedure btn1Click(Sender: TObject);
  12. private
  13. { Private declarations }
  14. public
  15. { Public declarations }
  16. end;
  17. var
  18. Form1: TForm1;
  19. implementation
  20. {$R *.dfm}
  21. { Incrementa el valor del botón en 1. }
  22. procedure TForm1.btn1Click(Sender: TObject);
  23. var
  24. valorActual: Integer;
  25. begin
  26. valorActual := StrToInt(btn1.Caption);
  27. valorActual := valorActual + 1;
  28. btn1.Caption := IntToStr(valorActual);
  29. end;
  30. { Reinicia el incremento del botón a 1. }
  31. procedure TForm1.btn2Click(Sender: TObject);
  32. begin
  33. btn1.Caption := '1';
  34. end;
  35. end.