Re: add one every time in Delphi codePosted by Joey *DClub* on July 22, 2004 In Reply to: add one every time posted by steve on July 21, 2004 One thing is... this will always show 1 as i is freed at the end of the function so under the "Public" or "Private" clause in the TForm type you need to have i: Integer set there. Computers have a special circuitry thats designed to add one so inc(i) is your better option and IntToStr should work fine ;) so your overall code in a blank template should be... unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Timer1: TTimer; Label1: TLabel; procedure Timer1Timer(Sender: TObject); private { Private declarations } public i: Integer; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Timer1Timer(Sender: TObject); begin Inc(i); Label3.Caption := IntToStr(i); end; end. This worked fine for me ;) Joey ^__^
|