Formatting exactly one decimal point

  • Thread starter John S. Ford, MD
  • Start date
J

John S. Ford, MD

I want to use the Round() function to format some data for a report. How
can I do this in such a way that numbers ALWAYS have one digit to the right
of the decimal place for example:

1.0
1.1
10.0
10.1
100.0
100.1

Using the Round() function works unless the number is a perfect whole number
in which case I get this:

1
10
100

How can I avoid dropping the decimal point for whole numbers?

John



--
-------------------------------------------------------
John S. Ford, MD, MPH
Assistant Professor of Medicine
David Geffen School of Medicine at UCLA
Harbor-UCLA Medical Center
(e-mail address removed)
http://califmedicineman.blogspot.com
 
T

Tom Lake

John S. Ford said:
I want to use the Round() function to format some data for a report. How
can I do this in such a way that numbers ALWAYS have one digit to the right
of the decimal place for example:

Instead of Round, use Format(n, "#.0")

Tom Lake
 
M

Marshall Barton

I want to use the Round() function to format some data for a report. How
can I do this in such a way that numbers ALWAYS have one digit to the right
of the decimal place for example:

1.0
1.1
10.0
10.1
100.0
100.1

Using the Round() function works unless the number is a perfect whole number
in which case I get this:

1
10
100

How can I avoid dropping the decimal point for whole numbers?


Round is a calculation function, not a formatting function.

The formatting of a text box can almost always be done by
using the text box's Format property. In this case, the
trivial custom format:
0.0
will display the number with one decimal place AND round the
displayed value to fit the format.
 

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