VB自定义函数调用!解决思路

VB自定义函数调用!
Function   round2(a   As   Integer)   As   Integer

If   1000   >   a   > =   100   Then   round2   =   Round(a,   0)
If   100   >   a   > =   10   Then   round2   =   Round(a,   1)
If   10   >   a   > =   1   Then   round2   =   Round(a,   2)
If   a   <   1   Then   round2   =   Round(a,   3)
End   Function

我要求四舍六入的同时保留三位有效字这样自定义对吗?大于100保留0位小数,大于10小于100保留1位小数,小于1保留3位小数。这样就可以达到保留三位有效数字,同时用round函数就是四舍六入了。在程序里试了一下不行,不知道是自定义函数写的不对,还是我调用的有问题呀


------解决方案--------------------
Private Function round2(a, b As Integer) As Integer

If a < 1000 And a > = 100 Then round2 = Round(a, 0)
If a < 100 And a > = 10 Then round2 = Round(a, 1)
If a < 10 And a > = 1 Then round2 = Round(a, 2)
If a < 1 Then round2 = Round(a, 3)
End Function

Private Sub Command1_Click()
Dim a As Integer

a = Val(Text1.Text)
b = round2(a, 2)

Text2.Text = b
End Sub
经过测试,没有问题的代码,但是没有实现你的问题