Round off number to next 10

Discussion in 'C#' started by eLucknow.com, Aug 20, 2008.

  1. #1
    it is easy to use round function in asp to round off decimal digit. but how can i round off number (ex 5862) to next 10 (as 5870) using asp.
     
    eLucknow.com, Aug 20, 2008 IP
  2. engager

    engager Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When I see no pratical solution I do my own function.
    try this

    function RoundToNextTen(num)
    if (num / 10) = CLng(num / 10) then
    RoundToNextTen = num
    else
    RoundToNextTen = (CLng(num / 10) + 1) * 10
    end if
    end function
     
    engager, Aug 21, 2008 IP
  3. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #3
    The simplest way would be this

    Private Function RoundToTen(ByVal num)
    Return num - (num Mod 10) + 10
    End Function



     
    vihutuo, Aug 22, 2008 IP