- Home
·
- Miscellaneous
·
- This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe
This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe
This function is used to round a number (single). With the parmeter "rl_NumberOfDecDigits", you specify the number of decimal digits in the
Rate This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe
(1(1 Vote))
Public Function Round(rf_Number As Single, rl_NumberOfDecDigits As Long) As Single
'Public function:
'This function is used to round a number (single).
'With the parmeter "rl_NumberOfDecDigits", you specify the number of decimal 'digits in the
'calculation result.
On Local Error GoTo ERR_H
'------------
'Declarations
'------------
Dim md_Temp As Double 'a temporary variable
Dim ml_AntiLog As Long 'antilogarithm
'----
'Code
'----
'Change long into double
md_Temp = CDbl(rf_Number)
'Antilogarithm
ml_AntiLog = 10 ^ rl_NumberOfDecDigits
'Calculate the return value
Round = (Fix((md_Temp + 0.5 / ml_AntiLog) * ml_AntiLog)) / _
ml_AntiLog
Exit Function
'------------
ERR_H:
'------------
MsgBox "Something is wrong !", vbInformation + vbOKOnly
End Function
This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe Comments
No comments yet — be the first to post one!
Post a Comment