rounding

xiaoxiao2021-03-06  61

Public Function Roundf (Number, Optional Numofdigits as long) AS DOUBLE

IF not isnumeric (Number) THEN EXIT FUNCTION

DIM IPOS As Long

IPOS = INSTR (Number, ".")

Dim dbdesimalpart as long

DIM DBROUNDPART AS Long

IF ipos> 0 THEN

DBDesimalPart = MID (Number, IPOS 1)

END IF

IF Numofdigits

DBROUNDPART = MID (DBDesimalpart, Numofdigits 1, 1)

END IF

IF dBroundpart> 4 THEN

DBDesimalpart = Left (dbdesimalpart, numofdigits) 1

Else

DBDesiMalpart = Left (dbdesimalpart, numofdigits)

END IF

Roundf = Val (int (Number) & "." & Dbdesimalpart)

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-112823.html

New Post(0)