formatting a number

I want to format a number but i don’t know how. i use this formatSpec–>"###############.##0.00"

dim number as currency number = 0.003 msgbox str(number, "###############.##0.00")

I use Str because i don’t need localization

with the above formatSpec i get this

if number is 623201.568 i want to get 623201.57 but with the above formatSpec i get 623201.56800
if number is 0 i want to get 0.00 but with the above formatSpec i get 0.000
if number is 125 i want to get 125.00 but with the above formatSpec i get 125.000
if number is 125.009 i want to get 125.01 but with the above formatSpec i get 125.00900

my question is… what formatSpec should i use?

Format(number,"#.00")

That should give you the results that you are looking for.

thanks @Jared Feder ! works great!

Your code is this:

dim number as currency number = 0.003 msgbox str(number, "###############.##0.00")

If you look at your formatting there are two “.” characters. This means that Xojo is not using:

"###############.##0.00"

but using

"###############.##0"

This is returning the correct format as you have supplied. I surmise that the first “.” is a thousands separator. If that is true then use:

"#,0.00"

as the format and you would get “623,201.57” as the result of 623201.568.