Results 1 to 4 of 4

Thread: [RESOLVED] Silly question (Rounding)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    205

    Resolved [RESOLVED] Silly question (Rounding)

    Have searched as always but it appears all the rounding done if for numbers like 10.34354 etc

    I need to round off to the nearest 10 but not least, example


    10 would stay as 10
    11 would be 20
    3 would be 10
    22 would be 30

    Thanks in advance
    If you can’t help, dont change the subject with useless questions about the problem

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Silly question (Rounding)

    try this
    VB Code:
    1. x = ((y \ 10) * 10) + IIf(y Mod 10, 10, 0)
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: Silly question (Rounding)

    Or:

    y = -Int(-x/10)*10
    Last edited by jeroen79; Oct 17th, 2006 at 11:01 AM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    205

    Re: Silly question (Rounding)

    Thanks!
    If you can’t help, dont change the subject with useless questions about the problem

Posting Permissions

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



Click Here to Expand Forum to Full Width