本文介绍了乘以值时,输入字符串的格式不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将标签文本转换为整数并乘以时,输入字符串不正确...



我尝试过:



  private   void  GrandTotal()
{
int GTotal = 0 ;
for int i = 0 ; i < BillingGridView.Rows.Count; i ++)
{
String total =(BillingGridView.Rows [i] .Cells [ 7 ]。Text);
GTotal + = Convert.ToInt32(total.ToString());
}
BillTotalLabel.Text = GTotal.ToString();
if (BillTotalLabel.Text!=
{
int billtotal = Convert.ToInt32(BillTotalLabel.Text);
int vat = Convert.ToInt32(VATPerLabel.Text.ToString());
int totalaftervat = billtotal * vat / 100;
VATValueLabel.Text = totalaftervat.ToString();
}
}
解决方案




get input string was not in correct for when converting label text to integer and multiplying...

What I have tried:

private void GrandTotal()
    {
        int GTotal = 0;
        for (int i = 0; i < BillingGridView.Rows.Count; i++)
        {
            String total = (BillingGridView.Rows[i].Cells[7].Text);
            GTotal += Convert.ToInt32(total.ToString());
        }
        BillTotalLabel.Text = GTotal.ToString();
        if (BillTotalLabel.Text != "")
        {
            int billtotal = Convert.ToInt32(BillTotalLabel.Text);
            int vat = Convert.ToInt32(VATPerLabel.Text.ToString());
            int totalaftervat = billtotal * vat/100;
            VATValueLabel.Text = totalaftervat.ToString();
        }
    }
解决方案




这篇关于乘以值时,输入字符串的格式不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 13:04