...

View Full Version : how do i used round function()



petertran123
02-11-2003, 02:19 PM
Hello all supporter

take the amount entered and add 100 to arrive at X. Round X up to the nearest 500.

let say i have 4010 + 100 = 4110 from 4110 how do i round up to 4500

some examples so you can have a picture what i'm talking about:

4250 + 100 = 4350 how do i round up to 4500
6600 + 100 = 6700 how do i round up to 7000
7100 + 100 = 7200 how do i round up to 7500


please help me as you can, thanks

raven
02-11-2003, 03:40 PM
I don't believe the round() function is the solution here. I would suggest something along these lines:

Function round500(intInput)

If intInput mod 500 = 0 then 'check if input is exactly divisible by 500

round500 = intInput

Else

intDivided = round(intInput/500) 'divide input by 500 and return integer value repesenting number of 500's that go into that number

round500 = (intDivided*1000) + 500

End if

End function



Use the function thus:

For this - 4250 + 100 = 4350 how do i round up to 4500 - use:

round500(4350)


Just noticed that I use round() in this function, so I guess you were working along the right lines!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum