VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Another (very easy) Rounding Function

by Matt Roberts (1 Submission)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

This code makes easy work of doing simple rounding on decimal number...something that VB currently lacks. Why didn't they think of this?

Inputs
Number (double data type)
Code Returns
RoundNum (Integer)
Side Effects
Rounding financial stuff is not cool :)

Rate Another (very easy) Rounding Function

' Paste this code directly into your IDE. This has not yet been tested on VBScript, but should work if you drop the type declarations.

Function RoundNum(Number As Double) As Integer
If Int(Number + 0.5) > Int(Number) Then
  RoundNum = Int(Number) + 1
Else
  RoundNum = Int(Number)
End If

End Function

Download this snippet    Add to My Saved Code

Another (very easy) Rounding Function Comments

No comments have been posted about Another (very easy) Rounding Function. Why not be the first to post a comment about Another (very easy) Rounding Function.

Post your comment

Subject:
Message:
0/1000 characters