Forum > Beginners

How to send anything direkt to label1?

(1/2) > >>

coradi:
Hi,
I try to show the Time.
This work if I write the routine into Button1click and send the value to label1.
But I would start it in an loop and send the time all the time to label1.
But with this it sais that Label1 not found.
I think my fault is to understand to work with Rekords?


--- Code: ---{ TForm1 }

procedure TForm1.Label1Click(Sender: TObject);
begin

end;   

and

Begin
 While TRUE DO
Begin
  Label1.Caption := TimeToStr(now);
  end;
end; 
--- End code ---

GetMem:
Drop a TTimer to your form, set Interval to 10. Double click the TTimer:

--- Code: ---procedure TForm1.Timer1Timer(Sender: TObject);
begin
  label1.Caption := FormatDateTime('hh:mm:ss:zzz', now);
end;
--- End code ---

PS: If you want a more precise timer, you should create a thread.

coradi:
ah ok, for first try, this will work :-)

And If I try to PRgramm something liek a calculator..how can I do, that If I press Button 1 that send the numer 1 to label...and press it again, that label is not 1 ..they should be 11 and so on..

No, it't not for Homework :-)
I'm try to learn FPC :-)
and need motivation Projekts :-)

GetMem:

--- Quote ---No, it't not for Homework :-)
--- End quote ---
Yes, it is! But I don't care!  :D

Click Label1, set Caption property to ''.

--- Code: ---procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := Label1.Caption + IntToStr(1);
end;

--- End code ---

coradi:
really!! no homework.
Great this works, it was to easy, I think I am to intelligent for this easy stuff that I can't found it haha
Thanks
I liek the Pascal Community it's much more friendly than the C Freaks

Navigation

[0] Message Index

[#] Next page

Go to full version