注册 登录
编程论坛 VB6论坛

为什么小数点前面的零没了?后面一个文本框明明保留的三位小数,结果后面好多零,报错类型不匹配

凛冬1 发布于 2020-03-20 20:50, 2136 次点击
Private Sub Combo2_click()
Text2.Text = Val(Combo1.Text) * Val(Combo2.Text) * 0.000001
Text2 = Format(Val(Text2), "#0.###")
End Sub
为什么这个代码出来的小数点前面的零没了
只有本站会员才能查看附件,请 登录


Private Sub Text14_Change()
Text15.Text = 100 * (Val(Text14.Text) - Val(Text3.Text)) / Val(Text3.Text) & "%"
Text15 = Format(Val(Text15), "0.000")
End Sub
这段代码在Text15 = Format(Val(Text15), "0.000")处显示类型不正确,而且为什么保留的小数位数也不对?
只有本站会员才能查看附件,请 登录
3 回复
#2
show1472020-03-21 15:28
这个应该没有问题呀,要不然你把源代码贴上来
#3
凛冬12020-03-21 19:10
回复 2楼 show147
我把%去掉就都没问题了,也不知道为啥
#4
JaneJackson2020-08-24 14:45
如果小数点前没有0的话你把这段代码跟在后面:
If Text1.Text > 0 And Text1.Text < 1 Then
Text1 = IIf(Left(Text1.Text, 1) = ".", 0 & Text1.Text, Text1.Text)
End If
If Text1.Text > -1 And Text1.Text < 0 Then
Text1 = "-0" & (Text1.Text * -1)
End If
1