shsh_shah
Member
- Joined
- Aug 29, 2012
- Messages
- 5
- Programming Experience
- Beginner
hello,
I have below code and i am trying to get the values of all textboxes and then adding it in totaltextbox but currently it takes only current textbox and when it leaves to 2nd it forgets the first one.
Any help please?
I have below code and i am trying to get the values of all textboxes and then adding it in totaltextbox but currently it takes only current textbox and when it leaves to 2nd it forgets the first one.
Any help please?
C#:
private void textBoxes_TextChanged(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
if (tb != null)
{
decimal temp = 0;
if (decimal.TryParse(tb.Text, out temp))
{
if (temp > 1)
MessageBox.Show("Please enter the nnumber between 0 and 1.");
}
}
}
private void textBoxes_Leave(object sender, System.EventArgs e)
{
decimal total = 0;
TextBox tb = sender as TextBox;
if (tb != null)
{
decimal temp = 0;
if (decimal.TryParse(tb.Text, out temp))
{
total += temp;
totalTimetxtBox.Text = total.ToString();
}
}
}