VB中输出0点几的时候不显示小数点前面的零4怎么让他显示呢?

来源:百度知道 编辑:UC知道 时间:2024/06/05 15:10:42
使用Format函数 ,print format(1/3,"0.0000") 显示的就是0.3333
这种方式不行!!!!!!!!!!!!
function strnum(i as single) as string
if abs(i)<1 and i<>0 then
if i>0 then
strnum="0" & trim(i)
else
strnum="-0" & trim(abs(i))
end if
end if
end function
这种方式也不行
我的提问有歧义,我是想让他显示前面的0,但是这些方法都不行!一楼和二楼的方法也不行

1)使用Format函数格式显示小数。

Format 函数,返回 Variant (String),其中含有一个表达式,它是根据格式表达式中的指令来格式化的。

Private Sub Form_Click()
    Debug.Print Format(4 / 10, "0.0000")
    Debug.Print Format(1 / 7, "0.######")
End Sub

2)开始菜单-控制面板-时间、语言和区域-更改日期、时间或数字格式-其它设置-零起始显示-选0.7。

你是让他显示还是不显示?
显示:print format