Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding comma or . seperation to a number stored in a string

1 view
Skip to first unread message

Gino A. Costa

unread,
Mar 12, 2003, 12:18:33 AM3/12/03
to
Hello
I'm using Delphi 6 PRO. If I have a lerge (over 1,000) number stored in an
integer, is there a way I can add commas or . or the other character to
seperate thousands, depending on the country, if I add the value to a
string, as if I'm using IntToStr ()?

Thanks,
Gino Costa


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----

AlanGLLoyd

unread,
Mar 12, 2003, 1:52:00 AM3/12/03
to
In article <3e6ec3e6$1...@corp.newsgroups.com>, "Gino A. Costa"
<gco...@beld.net> writes:

>I'm using Delphi 6 PRO. If I have a lerge (over 1,000) number stored in an
>integer, is there a way I can add commas or . or the other character to
>seperate thousands, depending on the country, if I add the value to a
>string, as if I'm using IntToStr ()?
>

Use Format() function. Look up "format strings" in help.

MyStr := Format('%.0n', [MyInteger * 1.0]);

The function needs a floating point type, and the " * 1.0" fools it into taking
an integer. The separators are taken from window's thousand separator and so
are whatever is required in the country of use.

The Format() function is a good one to get to know, you can include other text
in the formatting string so do not have to code concatenation ...

MyStr := Format('Size is %.0n whatnots', [MyInteger * 1.0]);

Alan Lloyd
alang...@aol.com

0 new messages