Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal-to-string formatting

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
572
US
Colleagues,

Say, I have some numeric value of type Decimal (it's actually a dollar amount), and I need to insert it to a string.
lnChkValue.ToString() works (but of course!), however:

if it's, say, 123.45 - it gives "123.45"

but

if it's 123.40 - it gives "123.4" (zero's lost)

I tried to find the answer on how to format the output of the Decimal.ToString() on the MS documentation... and either I'm a total dullard, or there's nothing to answer my question there indeed.

(There's a TRANSFORM() function in VFP, which would allow me something like TRANSFORM(lnChkValue, "@ ###.##") and the output would be "123.40"... just FYI.)

TIA!

Regards,

Ilya
 
Works!

[thanks]

Actually, it s./b. Format(lnChkValue, "###.00"), but it's a small detail.
Thank you, colleague!

Regards,

Ilya
 
Ah, you asked for 'something like TRANSFORM(lnChkValue, "@ ###.##")', so that's what I gave you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top