vb中如何让textbox显示计算除法后的结果
如题,在做计算器,但是显示除法结果后显示结果不太如意,怎么控制结尾的0??入结果是0.4就显示0.4,别显示0.400000
但是如果是除不尽的,要保留总位数为11位,且结尾不带0
就是你这样写的啊,执行你的程序,在我机器上就是按你要求显示的. 显示0.4,而不是0.40000000…
Private Sub Command10_Click()
Dim sum As Double
If cost1 <> 0 And str <> "" Then
Select Case str
Case "+"
sum = cost1 + Val(Text1.Text)
Text1.Text = sum
str = ""
Case "-"
sum = cost1 - Val(Text1.Text)
Text1.Text = sum
str = ""
Case "*"
sum = cost1 * Val(Text1.Text)
Text1.Text = sum
str = ""
Case "/"
sum = cost1 / Val(Text1.Text)
Text1.Text = Format(sum, "0.############")
str = ""
End Select
End If
End Sub
你算一下1/555555 又不是Format显示,怎么会显示0.400000?
=0.000001800002
我计算1/555555,结果就显示0.000001800 以上正解
补充:VB , 基础类