Avatar of Peter Kiers
Peter Kiers
Flag for Netherlands asked on

Round off a number after a calculation.

Hi,

I am programming in VS2010 with C#.
I have this code:

            if (e.Column.FieldName == "Value")
            {
                if ((Properties.Settings.Default.IsMGDL == false) && (CheckType(e.Value.ToString()) == false))
                {
                    int eValue = Convert.ToInt32(e.Value) / 18;
                    e.DisplayText = (eValue).ToString();
                }
                else if ((Properties.Settings.Default.IsMGDL == true) && (CheckType(e.Value.ToString()) == true))
                {
                    double eValue = Convert.ToDouble(e.Value) * 18;
                    e.DisplayText = (eValue).ToString();
                }
            }

Open in new window


In the first condition the calculated number has to round up in 1 decimal after the period.
or in my case the comma (f.e: 6,66666 has to be 6,7)

And in the second condition the calculated number as to round up as a whole number.
(f.e: 6,66666 has to be 7)

I hope I have explained it right!

How can I do that?

Peter
.NET Programming

Avatar of undefined
Last Comment
Peter Kiers

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dirk Haest

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Peter Kiers

ASKER
Thanks 500 p's comming to you...

Peter
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23