不好意思,给您添麻了!,一下是我的函数,请指教!!!
Function cmcrnd(anumber As Integer) As Integer
anumber = Int(anumber * 10 ^ 6) / 10 ^ 6
Dim a, n As Integer
Dim a1 As Byte
Dim t As String
n = 0
a = anumber
t = Mid(Trim(Str(FormatNumber(a - Int(a), 4, , , vbUseDefault))), 2)
For a1 = 1 To 4
If Mid(t, a1, 1) <> "0" Then
Exit For
Else: n = n + 1
End If
Next
If Eval(Right(Str(Int(a * 1000 * 10 ^ n)), 1)) > 5 And Eval(Right(Str(Int(a * 100000)), 2)) > 0 Then
a = Int(a * 100 * 10 ^ n + 1) / (100 * 10 ^ n)
Else:
If Eval(Right(Str(Int(a * 1000 * 10 ^ n)), 1)) = 5 Then
If Eval(Right(Str(Int(a * 100 * 10 ^ n)), 1)) Mod 2 = 0 Then
a = Int(a * 100 * 10 ^ n) / (100 * 10 ^ n)
Else: a = Int(a * 100 * 10 ^ n + 1) / (100 * 10 ^ n)
End If
Else: a = Int(a * 100 * 10 ^ n) / (100 * 10 ^ n)
End If
End If
Select Case no
Case 1
a = FormatNumber(a, 3)
Case 2
a = FormatNumber(a, 4)
Case 3
a = FormatNumber(a, 5)
End Select
cmcrnd = a
End Function
[此贴子已经被作者于2002-6-30 8:58:48编辑过]
|