Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    160
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how do i used round function()

    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

  • #2
    New Coder
    Join Date
    Jan 2003
    Location
    Peterborough, UK
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!
    Last edited by raven; 02-11-2003 at 04:45 PM.


  •  

    Posting Permissions

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