Delphi beginners

Moderators: netgert
Number of threads: 358
Number of posts: 982

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Zero fill when showing value on a label? Posted by CLCase on 15 Oct 2006 at 2:00 PM
Hello,

I'm showing a constant changing value on a TLabel:

a: double;
Label1.Caption := FloatToStr(a);

If the value is 15.4 it looks like this:
15.4

But if the value is 15.0 it looks like this:
15

I want it to be shown with one decimal no matter if the decimal will be 0.
Like this:
15.0

How can I do this the fastest way (for the processor)?


Thanks in advance!


Report
Re: Zero fill when showing value on a label? Posted by zibadian on 15 Oct 2006 at 4:23 PM
: Hello,
:
: I'm showing a constant changing value on a TLabel:
:
: a: double;
: Label1.Caption := FloatToStr(a);
:
: If the value is 15.4 it looks like this:
: 15.4
:
: But if the value is 15.0 it looks like this:
: 15
:
: I want it to be shown with one decimal no matter if the decimal will be 0.
: Like this:
: 15.0
:
: How can I do this the fastest way (for the processor)?
:
:
: Thanks in advance!
:
:
:
Use the Format() function to perform the conversion.
Report
Re: Zero fill when showing value on a label? Posted by DanglingChap on 24 May 2007 at 6:00 AM
: : Hello,
: :
: : I'm showing a constant changing value on a TLabel:
: :
: : a: double;
: : Label1.Caption := FloatToStr(a);
: :
: : If the value is 15.4 it looks like this:
: : 15.4
: :
: : But if the value is 15.0 it looks like this:
: : 15
: :
: : I want it to be shown with one decimal no matter if the decimal will be 0.
: : Like this:
: : 15.0
: :
: : How can I do this the fastest way (for the processor)?
: :
: :
: : Thanks in advance!
: :
: :
: :
: Use the Format() function to perform the conversion.
:

FormatFloat('##.0', a)

# means if there will be some number it will be displayed else it will be omited.
0 means if there is some number it will be displayed else 0 will be shown.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.