VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Round, Ceiling, Floor Function

by Jacky Wong (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

I found the round function from the vbcoders.com 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.

Rate Round, Ceiling, Floor Function

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 

Download this snippet    Add to My Saved Code

Round, Ceiling, Floor Function Comments

No comments have been posted about Round, Ceiling, Floor Function. Why not be the first to post a comment about Round, Ceiling, Floor Function.

Post your comment

Subject:
Message:
0/1000 characters