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
Loading
VulpesPosted Jun 22, 2012, 4:25 AM
If they are empty and you try to convert them to an integer, then you will get this exception.
Kunal VaishyaPosted Jun 22, 2012, 2:25 AM
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