VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe

by Schuster St. (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 15th November 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



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


Download this snippet    Add to My Saved Code

This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe Comments

No comments have been posted about This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe. Why not be the first to post a comment about This function is used to round a number (single). With the parmeter rl_NumberOfDecDigits, you spe.

Post your comment

Subject:
Message:
0/1000 characters