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

Rounding numbers

Status
Not open for further replies.

goatsaregreat

Programmer
Mar 21, 2001
82
GB
I have figured out my backspacing problem. Now I have something else... I need to round numbers to whole numbers. I have a mathmatical expression that will almost always return a whole number and a decimal. I need to clear the decimal and round to the nearest whole number. Is there some way to do this by formatting or what? TIA for your quick help.
 
Hi All,

Just to add:

The Round Function is the function to use but be aware in the case of '.5' it does round down instead of up.

i.e. Round(0.5) produces an integer of 0 instead of 1.

so you may want to add some code to check for this.

Regards,

Codefish
 
Hi Codefish

Are you sure about that ? I ran a simple test

Debug.Print Round(1.5)

and I get 2 as a result (vb6 sp5)

Jon

 
Sorry Codefish didn't read your statement close enough.
Round(.5) does return 0. All other instances it rounds properly

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top