rounding numbers in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vlagac
    New Member
    • Aug 2007
    • 1

    rounding numbers in VB

    how to round numbers to neirest 50 or 100..
    example 1273 to 1250
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by vlagac
    how to round numbers to neirest 50 or 100..
    example 1273 to 1250
    Can you explain detail and post your requirement?

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      There may be a function already available to do the job, but here's a user-defined function I quickly threw together, which seems to work...

      [CODE=vb]Public Function RoundedTo(ByVal Interval As Long, ByVal Value As Long) As Long
      ' Round Value to the nearest Interval.
      Dim Temp As Long
      Temp = Value / Interval
      RoundedTo = Temp * Interval
      End Function[/CODE]

      Comment

      Working...