home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_refer / roundoff / round.txt
Text File  |  1993-11-19  |  667b  |  24 lines

  1. Function Round (n, d)
  2.  
  3. ' Accepts: a variant value
  4. ' Purpose: converts multiplace decimal numbers
  5. ' Returns: a number rounded to d decimal places
  6. '          or a zero if the value it was called for was null
  7. '          If d is negative or null d is set to 0 and the function is like Int()
  8. '          In any case d is set to Int(d)!
  9. ' Author:  Marcus O. M. Grabe, CIS 100120,1405
  10. '          Please send a message, if you like it or if you have any suggestions.
  11.  
  12.  If IsNull(n) Or IsNull(d) Then
  13.     Round = 0
  14.  Else
  15.     If d < 0 Then
  16.        d = 0
  17.     Else
  18.        d = Int(d)
  19.     End If
  20.     Round = CLng(n * (10 ^ d)) / (10 ^ d)
  21.  End If
  22.  
  23. End Function
  24.