Round to nearest even dollar

Stimulsoft Reports.NET discussion
jrSD
Posts: 23
Joined: Wed Jun 10, 2015 8:10 pm

Re: Round to nearest even dollar

Post by jrSD »

Ivan wrote:Hello,
jrSD wrote:Is there a better way to accomplish this?
If you need to use this expression in several places, it is better to describe it as a function, and use this function in expressions.
For example, you can add following function into the report, on the Code tab of designer:

Code: Select all

		Function MyRound(ByVal num As Double) As Double
			MyRound = CInt((Math.Round(num+0.00001,4)+1)/2)*2
		End Function
and then use this function in expressions:

Code: Select all

{MyRound(3.75)}
{MyRound(4.1)}
Thank you.

Brilliant! Thank you very much!!
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Round to nearest even dollar

Post by Ivan »

Hello,

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply