gpt4 book ai didi

vb.net - 如何将答案转换为两个小数点

转载 作者:行者123 更新时间:2023-12-04 16:18:48 24 4
gpt4 key购买 nike

这是我的代码,我想要的输出是txtA.TexttxtB.Text保留两位小数。

Public Class Form1
Private Sub btncalc_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btncalc.Click
txtA.Text = Val(txtD.Text) / Val(txtC.Text) * Val(txtF.Text) / Val(txtE.Text)
txtB.Text = Val(txtA.Text) * 1000 / Val(txtG.Text)
End Sub
End Class

最佳答案

尝试使用Format函数:

Private Sub btncalc_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btncalc.Click
txtA.Text = Format(Val(txtD.Text) / Val(txtC.Text) *
Val(txtF.Text) / Val(txtE.Text), "0.00")
txtB.Text = Format(Val(txtA.Text) * 1000 / Val(txtG.Text), "0.00")
End Sub

关于vb.net - 如何将答案转换为两个小数点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16581901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com