vb 格式化数目字

vb 格式化数字

99


格式化为2位小数     99.0
格式化为2位小数     99.00
格式化为3位小数     99.000
格式化为4位小数     99.0000
格式化为5位小数     99.00000


代码如何实现?

------解决方案--------------------
format(99,"0.0")
format(99,"0.00")
.....
------解决方案--------------------
'参数data-->数据,decNum-->小数位数
Function FormatData(ByVal data As Double, ByVal decNum As Integer) As String
    Dim s As String
    s = Format(data, "0." & String(decNum, "0"))
    FormatData = s
End Function
要一次性,自己循环来调用这个函数