Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > API and Miscellaneous sample source codes
Function to round a value up,down,or near to another value.
Function to round a value up,down,or near to another value. Function doRound(value As Double, RStep As Double, Mode As String) As Double ' Mode function ' UP RoundUp ' DN RoundDN ' NE Nearest ' If Mode = "DN" Then doRound = (Int(value / RStep) * RStep) Exit Function End If ' **** mode up If Mode = "UP" Then If value Mod RStep > 0 Then doRound = ((Int(value / RStep) * RStep) + RStep) Else doRound = value End If Exit Function End If If Mode = "NE" Then value = value + (RStep / 2) doRound = (Int(value / RStep) * RStep) Exit Function End If End Function
Privacy Policy
|
Link to Us
|
Links