Click here to Skip to main content
15,902,918 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am creating windows application using c# 2010, here I am using data grid view for billing purpose, I am enter the values in grid columns that values are shown on text box, once value is increase > 100 in first text box, automatically adding +1 for second text box,
how to create in c# windows application I am using below code but not working. Please give me any one ideas.
int first;
int sec;

first = int.Parse(textBox2.Text);
sec = int.Parse(txt_netamount.Text);

if (first > 100)
{
   sec +=1;
}


What I have tried:

How to calculating text box values
Posted
Updated 19-Sep-16 6:43am
v2
Comments
Maciej Los 19-Sep-16 14:30pm    
33 questions but non of them is marked as "solved". Why???

1 solution

The integer variable sec is increased but the new value of the variable isn't automatically shown in the text box, you need to set it. Try the following:

C#
int first;
int sec;
 
first = int.Parse(textBox2.Text);
sec = int.Parse(txt_netamount.Text);
 
if (first > 100)
{
   sec +=1;
   txt_netamount.Text = sec.ToString();
}
 
Share this answer
 
Comments
Boopalslm 19-Sep-16 12:46pm    
It's working good thanks for your help, it's same time minus 100 for textBox2 how to create.
Wendelius 19-Sep-16 13:51pm    
The idea is the same, you get the values from text box, do the calculation, set the values to the text box. Something like

int first;
int sec;

first = int.Parse(textBox2.Text);
sec = int.Parse(txt_netamount.Text);

if (first > 100)
{
sec +=1;
txt_netamount.Text = sec.ToString();
first -= 100;
textBox2.Text = first.ToString();
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900