Help concerning rounding.

  • Thread starter Thread starter zykon
  • Start date Start date
Z

zykon

Guest
Hello
I have recently started using VBA at school. I am stuck trying to make one of my fields to behave as required. The problem is that i want to input a weight in kilograms, but round it to the nearest 5 grams. eg
7.456 Kg would become 7.46 Kg
How would i go about this and if anyone could suggest a code to do this it would be appreciated. Please note that i am very unfamilar with VBA so could answers please be as simple as possible.
Thanks for your help
Zykon
 
I think this is how it is done,

round(weight + 0.005,2)

The + 0.005 is so that if the weight will round up if above 7.455.

Todd
 
Check the "Round Function" in the help file. :o
 
Two points I believe that the round function is only available in 2003 and also that it may not quite work in the way you would expect eg it rounds down .5 not up ( I am sure I will be corrected here if I am wrong ). I have done a quick search of the forum and i cant find the references to this. However if you do a search for "rounding" you will find a number of threads on this issue along with some code that will solve your problem if you cant use the round function.
 

Users who are viewing this thread

Back
Top Bottom