need to get the nearest 10 interval

# Thread: need to get the nearest 10 interval

1. Senior Member
Join Date
Dec 1969
Posts
299

## need to get the nearest 10 interval

does anyone know a function that will get the nearest 10? for instance, if i=2 then i will now bw 10, and so on for the following...<BR><BR>3 --&#062; 10<BR>8 --&#062; 10<BR>12 --&#062; 20<BR>17 --&#062; 20<BR>24 --&#062; 30<BR><BR>etc...

2. Senior Member
Join Date
Dec 1969
Posts
1,849

## divide by 10 then add 1 then multiply by 10

integer rules, divide the number by 10, get rid of the decimal, add one, then multiply by 10...<BR><BR>-- Whol

3. Senior Member
Join Date
Dec 1969
Posts
299

## thanks!

worked great!

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## ** WRONG ANSWER **

Do that and 10 becomes 20!<BR><BR>10 10 [you did say integer division] --&#062;&#062; 1 <BR>1 + 1 [your rule] --&#062;&#062; 2<BR>2 * 10 --&#062;&#062; 20<BR><BR>*********************<BR><BR>Right answer has to be more complex:<BR><BR>Function Next10( num )<BR> If Num MOD 10 = 0 Then <BR> Next10 = num <BR> Else <BR> Next10 = 10 + 10 * (num 10)<BR> End If<BR>End Function<BR><BR>Yes, that&#039;s a backslash. That does integer division.<BR><BR><BR><BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
1,849

## they werent too specific, Simple answer...

wasn&#039;t wrong, just different results :-D

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## LOL...okay...

Despite the fact that the function is a very common one in financial transactions, we&#039;ll let you get away with that answer!<BR><BR>&#060;grin&#062; But I&#039;m storing up the points... &#060;/grin&#062;<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•