Recent

Author Topic: Variables in labels?  (Read 14044 times)

T-bear

  • Full Member
  • ***
  • Posts: 160
Variables in labels?
« on: October 10, 2010, 12:53:23 pm »
Hello
I have a little questions about labels:
Is it possible to show the value of a variable in a label, and if, how?
Thanks!

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Variables in labels?
« Reply #1 on: October 10, 2010, 01:00:20 pm »
Well, why not? Simply set the appropriate data type to the Caption property.

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Variables in labels?
« Reply #2 on: October 10, 2010, 01:13:53 pm »
And how do i do that?  :-[

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Variables in labels?
« Reply #3 on: October 10, 2010, 01:19:04 pm »
If the variable is of string type, simply set:

Code: [Select]
Label.Caption := variable;
If it is of integer type, set:

Code: [Select]
Label.Caption := IntToStr(variable);

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Variables in labels?
« Reply #4 on: October 10, 2010, 01:21:09 pm »
Thank you. :D

mas steindorff

  • Hero Member
  • *****
  • Posts: 560
Re: Variables in labels?
« Reply #5 on: October 11, 2010, 06:00:22 pm »
FYI
almost all the components have a .tag property that you can use for your self.  the int can be set to the value when you set it's label then you can access it faster later on.

read lables value
x:= strtoint(lable1.caption)
or
x := lable1.Tag

set labes value or the code above will not work
label1.caption := inttostr(x);  // set  text
lable1.tag := x;                   // and save as int
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

 

TinyPortal © 2005-2018