RE: Controlling number of decimal places

From: atw13 (atw13_at_discussions.microsoft.com)
Date: 02/25/05


Date: Thu, 24 Feb 2005 21:05:05 -0800

System.Decimal d = new System.Decimal(yourfloat);
String s = d.ToString("C");

The easiest way I see to do it is the above. Create a System.Decimal object
from your float, and then use the "c" argument in the toString method of
Decimal to format it as currency.



Relevant Pages

  • Re: Globalization not working as intended when using da-DK
    ... I don't have a clue why it would work at my server and not on yours. ... Dim s as String 'create a string and format it as currency. ... If you don't format the string as currency, no currency symbol change can occur. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Hi guys~ i wonder that why this simple code error!!
    ... the error message is printf is undeclared. ... testing.c:15: warning: float format, ... you have a printfformat string with an embedded '%'. ...
    (comp.lang.c)
  • Re: "round" - improvement suggestion
    ... should return a float number for round/100.0, which, due to IEEE floating point representation, may be different from ... by choosing the shortest string of digits that reconverts to the ... % format %.2f 34.258123 ... My sample aims only to show difference between round and format. ...
    (comp.lang.tcl)
  • Re: Why this works?!
    ... printf("%s", str); ... One common use is in building format strings. ... and you change to float simply by changing: ... The other nice use is to interpolate a max-width in string scanf ...
    (comp.lang.c)
  • Re: help! with code.
    ... > me to format the currency on my report in the following ... Function fncFormatRupeesAs String ... Dim strFormatted As String ...
    (microsoft.public.access.modulesdaovba)

Loading