Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
One Line RoundUp / One Line RoundDown
Author:
Timothy Cox
Submitted:
9/14/2010
Version:
VB6
Compatibility:
VB6
Category:
Mathematics
Views:
7604
Replaces http://www.a1vbcode.com/snippet-2916.asp -=Description from 2916 follows=- Two simple functions that are not found in VB. Suppose you have a number '3.376'. Now when you will use the RoundUp function you will get the result as '4.0'. By using RoundDown function the result would be '3.0'. However, for .NET you could use the Math.Floor and Math.Ceiling methods.
Declarations:
'none
Code:
Public Function RoundUp(Number As Double, Optional Places As Long = 0) As Double RoundUp = Round(Number + (5 / (10 ^ (Abs(Places) + 1))), Abs(Places)) End Function Public Function RoundDown(Number As Double, Optional Places As Long = 0) As Double RoundDown = Round(Number - (5 / (10 ^ (Abs(Places) + 1))), Abs(Places)) End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement