Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在vb.net中删除数字前面的0_Vb.net - Fatal编程技术网

如何在vb.net中删除数字前面的0

如何在vb.net中删除数字前面的0,vb.net,Vb.net,删除0。对于ex:01、001、0001、00001等,文本框中应自动或使用按钮变为1。请帮忙 您可以使用: 如果“0”应该是文本框上的有效输入,您可以使用或使用解决方案: txtNumber.Text = txtNumber.Text.TrimStart({"0"c}) 'solution using Integer.TryParse Dim intValue As Integer = 0 Integer.TryParse(txtNumber.Text, intValue) txtNumbe

删除0。对于ex:01、001、0001、00001等,文本框中应自动或使用按钮变为1。请帮忙

您可以使用:

如果“0”应该是
文本框上的有效输入
,您可以使用或使用解决方案:

txtNumber.Text = txtNumber.Text.TrimStart({"0"c})
'solution using Integer.TryParse
Dim intValue As Integer = 0
Integer.TryParse(txtNumber.Text, intValue)
txtNumber.Text = intValue

'solution using Decimal.TryParse
Dim decValue As Decimal = 0.0
Decimal.TryParse(txtNumber.Text, decValue)
txtNumber.Text = decValue