article

Round, Ceiling, Floor Function

Email
Submitted on: 1/23/2015 8:12:00 AM
By: Jacky Wong (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB 6.0
Views: 1444
 
     I found the round function from the planet source code before and I grouped it with my own ceil and floor function together. I hope these could help someone who don't want to use the round and format function to handle the numeric information.

 
				Public Function AdvRound(InValue As Double, InDecimal As Integer) As Double 
Dim lDblProcess As Double

lDblProcess = InValue * (10 ^ InDecimal)
AdvRound = Int(lDblProcess + 0.5) / (10 ^ InDecimal)
End Function

Public Function AdvCeil(InValue As Double, InDecimal As Integer) As Double
Dim lDblProcess As Double
lDblProcess = InValue * (10 ^ InDecimal)
If Int(lDblProcess) < lDblProcess Then
lDblProcess = Int(lDblProcess) + 1
Else
lDblProcess = Int(lDblProcess)
End If
AdvCeil = lDblProcess / (10 ^ InDecimal)
End Function

Public Function AdvFloor(InValue As Double, InDecimal As Integer) As Double
Dim lDblProcess As Double
lDblProcess = InValue * (10 ^ InDecimal)
AdvFloor = Int(lDblProcess) / (10 ^ InDecimal)
End Function


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.