rent textbox 1000 i have one button called calculate when i click the calculate button tax amt 100 comes
tax textbox 100(10 Percentage of rent) which comes 100
grossrent textbox 1100
then ihave another button called add for adding rent and tax the result will be fetch in to gross rent.
for that adding rent and tax i written the following code as follows
int a, b, c;
a = Convert.ToInt32(txt_rent.Text);
b = Convert.ToInt32(txt_tax.Text);
c = a + b;
txt_grossrent.Text = c.ToString();
when i click the add button error comes
input string was not in correct format.please help me thanks
rgds,
narasimanP
Error input string was not in correct format
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kunal VaishyaRank #990 · 2K reputationPosted Jun 21, 2012, 10:25 PM EDT
int a, b, c; a = Convert.ToInt32(txt_rent.Text.trim.ToString());
b = Convert.ToInt32(txt_tax.Text.trim.ToString());
c = a + b;
txt_grossrent.Text = c.ToString();
Avoid the Spacing you want use "." then use Double instead of int
VulpesRank #55 · 29.2K reputationPosted Jun 22, 2012, 12:25 AM EDT
If they are empty and you try to convert them to an integer, then you will get this exception.