Rounding numbers

I

iksingh

hi

can someone help me to round numbers up or down, so if a number is 9.
it would go to 9.5 and if a number is 7.8 it will go to 8

any help would be greatly appreciated

thank
 
K

Ken Snell [MVP]

What if the number is 9.2? Does it go to 9.5? or to 9.0?

Give us more info about exactly what the rounding is supposed to do.
 
I

iksingh

hi


thanks for responding, if the number is
9.2 id like it to turn into 9
9.4 into 9.5
9.6 into 10

so the number is an integer or its 5.5 or 6.5
and so on

thank
 
K

Ken Snell [MVP]

Your rounding logic is not consistent.

9.2 goes to 9

but 9.6 goes to 10?

Are you sure of this? What is the logic to round down 9.2 and round up 9.6?
 
I

iksingh

im sorry

i think im a bit confused i have to have a field in which a weight i
put to the nearest 0.5 of a kilogram, a combo or list box has to man
value so its not convienient so i have to format the field so that if
acustomer puts in

8.1 rounds to 8
8.2 rounds to 8
8.3 rounds to 8.5
8.4 rounds to 8.5
8.5 its ok
8.6 rounds to 8.5
8.7 rounds up to 9
8.8 rounds up to 9
8.9 rounds up tp 9

does this seem correct

thanks again for you time and hel
 
T

Tim Ferguson

i have to have a field in which a weight is
put to the nearest 0.5 of a kilogram,


= IIf(Int(dblWeight*2)=0, dblWeight, Int(dblWeight * 2 + 0.5) * 0.5)

Hope that helps


Tim F
 

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