Rounding to a forced number of decimals

G

Gijs van Swaaij

Dear everyone,

I have a several numeric variables that need to be outputted as a
string (using the Cstr() function). However, I first want to round
those variables to a forced number of decimals (in most cases, 2
decimals). It works fine for most variables, except that something like
5.00 becomes just 5. Is there a way to let the string show those two
last decimals?

Thanks,
Gijs van Swaaij
 
B

Baz

Gijs van Swaaij said:
Dear everyone,

I have a several numeric variables that need to be outputted as a
string (using the Cstr() function). However, I first want to round
those variables to a forced number of decimals (in most cases, 2
decimals). It works fine for most variables, except that something like
5.00 becomes just 5. Is there a way to let the string show those two
last decimals?

Thanks,
Gijs van Swaaij

Use the Format function instead of Cstr, e.g.

Format(some_number,"#,##0.00")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top