提问人:さくら 提问时间:2/21/2022 最后编辑:James Zさくら 更新时间:3/12/2022 访问量:215
在我的 Visual Basic 代码中要更改的内容,以逗号格式以十进制显示总和
what to change in my visual basic code to display the sum in decimal with comma format
问:
我试图用逗号和小数显示总和,但使用此代码我只能显示总和的前 2 位数字,请帮我修复它。谢谢。
Private Sub btnsum_Click(sender As Object, e As EventArgs) Handles btnsum.Click
Dim sum
Dim a
Dim b
Dim c
a = Val(lblnum1.Text)
b = Val(lblnum2.Text)
c = Val(lblnum3.Text)
sum = (a + b + c)
lblsum.Text = Format(sum, "#,###,##0.00")
End Sub
答:
0赞
BASit Bulbulia
2/23/2022
#1
lblsum.text = sum.ToString("N", CultureInfo.InvariantCulture)
别忘了插入
Imports System.Globalization
0赞
fonz
3/12/2022
#2
尝试此格式lblsum.Text = Format(sum, "#,##0.00")
评论
lblSum.Text = sum.ToString("N")
Option Strict On
Dim a = Val(lblnum1.Text)
Option Infer On