Soma em Label

Delphi

06/07/2004

Gente tenho este código em um botão

Tenho uma variável
tot : integer;

no click de um botao tenho este código

begin
if Edit1.text = A then
begin
label1.Caption := inttostr(tot+1);
tot := strtoint(Label1.Caption);
end
else
ShowMessage(´burro´)
end;

Cada vez que clico ele acrescenta 1 dai vai somando 1,2,3,4 e me mostrando no label.
Minha dúvida é esta e a forma correta de se fazer isto???????


Uoquisala

Uoquisala

Curtidas 0

Respostas

Rômulo Barros

Rômulo Barros

06/07/2004

var
  Form1: TForm1;
  tot:integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Edit1.Text = ´A´ then
  begin
    inc(tot);
    Label1.Caption := IntToStr(tot);
  end;
end;



GOSTEI 0
POSTAR