一种可能的情况 - 你可能在你的txtQUANTITYPOS文本框中输入一个数字,但txtPricePOS文本框仍然是空的。因此,您可能会收到此错误,因为您的txtPricePOS文本框尚未包含数字。
你可以使用Double.TryParse代替,以确保您不会乘其它字符而不是数字:
继你如何执行它的一个例子:
private void txtQUANTITYPOS_TextChanged(object sender, EventArgs e)
{
double pricePos;
double qtyPos;
if (!double.TryParse(txtPricePOS.Text, out pricePos))
return; // Will return in case txtPricePOS.Text is not a number
if (!double.TryParse(txtQUANTITYPOS.Text, out qtyPos))
return; // Will return in case txtPricePOS.Text is not a number
txtTOTALPOS.Text = (pricePos * qtyPos).ToString();
}
来源
2017-03-07 14:06:47
ehh
你有GOOGLE上搜索您的问题或应我们为你做? –
某些文本框似乎不是'双'格式 –
可能重复的[输入字符串不是以正确的格式C#](http://stackoverflow.com/questions/9286319/input-string-was-not-在一个正确的格式的C - 锐) – crashmstr