Board index » delphi » Converting currency to string

Converting currency to string

I want to convert a currency value to a string with formatting (adding
dollar sign and commas). How can I do this?

The process seems unnecessarily complicated having to deal with
TFormatSettings, local ID, local ID index.

 

Re:Converting currency to string


Quote
Patrick Ryan <[email protected]> wrote in message

news:[email protected]

Quote
> I want to convert a currency value to a string with formatting (adding
> dollar sign and commas). How can I do this?

> The process seems unnecessarily complicated having to deal with
> TFormatSettings, local ID, local ID index.

Format('%m', [FloatVar]);

This uses whatever the regional settings are.

--
Ray Marron

Re:Converting currency to string


My thanks to Ray for the answer. Should I have figured out eventually to use
Format? Probably. But I believe the help system should have provided more
clues where to go. I think the Delphi help system is very good, but there
are lots of places where the information is lacking.
Quote
"Ray Marron" <[email protected]> wrote in message

news:[email protected]
Quote
> Patrick Ryan <[email protected]> wrote in message
> news:[email protected]
> > I want to convert a currency value to a string with formatting (adding
> > dollar sign and commas). How can I do this?

> > The process seems unnecessarily complicated having to deal with
> > TFormatSettings, local ID, local ID index.

> Format('%m', [FloatVar]);

> This uses whatever the regional settings are.

> --
> Ray Marron

Re:Converting currency to string


Quote
Patrick Ryan <[email protected]> wrote in message

news:[email protected]

Quote
> My thanks to Ray for the answer. Should I have figured out eventually to
use
> Format? Probably. But I believe the help system should have provided more
> clues where to go. I think the Delphi help system is very good, but there
> are lots of places where the information is lacking.

I did the same as you, even going so far as to complete a homebrewed
function using all the regional preferences before finding out about Format.
Oh well, it was good practise. :)

There was a recent discussion here about the possibility of putting together
some sort of index using common keywords and/or search terms that are
dissimilar to the function names being searched for.

--
Ray Marron

Re:Converting currency to string


P.S.  I think it was discussed in
borland.public.delphi.language.objectpascal

Other Threads