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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Text

Status
Not open for further replies.

MandoThrasher

Programmer
Joined
Jul 12, 2002
Messages
49
Location
US
I have a variable vAmount that I need to format as currency with commas and 2 decimal places. I can't find any kind of format function in actionscript. I'm using MX.
 
it didnt take the whole link copy and paste into window
 
That almost does it. Actually, let me revise my need. I need commas and no decimal place.
 
round decimals
Contributed by: Stuart S (stuartmx@xs4all.nl), 12/10/2001 (n=1523)

Here is a simple function that'll round a number of to any decimal place.
---------------------------------
Math.roundTo = function(num,dp){
var d = Math.pow(10,dp);
return Math.round(num*(d+0.00000001))/d;
};
--------------------------------
example:
Math.roundTo(1.2345,2)) //1.23
You can even use negative numbers for decimal places
Math.roundTo(12345,-2)) //12300

Regards,

oldman3.gif
 
Replace the "." with a coma, when done? Regards,

oldman3.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top