Click here to Skip to main content
15,077,931 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have four TextBox_TextChange events doing math problems. The problem is that when a user enters in the numbers and tabs to the next textbox they will have to enter in a nnumber into the textbox where the answer is going to be displayed in order for it to fire. Is there a way for me to change this?

protected void TextBoxTHUG_TextChanged(object sender, EventArgs e)
       int i = Convert.ToInt32(TextBoxTHUG.Text);
       int j = 12;
       TextBoxTHUGDR.Text = Convert.ToString(i / j);

   protected void TextBoxTHG_TextChanged(object sender, EventArgs e)
       int i = Convert.ToInt32(TextBoxTHG.Text);
       int j = 9;
       TextBoxTHGDR.Text = Convert.ToString(i / j);

   protected void TextBoxT1234_TextChanged(object sender, EventArgs e)
       int a = Convert.ToInt32(TextBoxFTUG.Text);
       int b = Convert.ToInt32(TextBoxFTG.Text);
       int c = Convert.ToInt32(TextBoxTHUGDR.Text);
       int d = Convert.ToInt32(TextBoxTHGDR.Text);
       int f = 0;
       TextBoxT1234.Text = Convert.ToString(a + b + c + d + 0); 

   protected void TextBoxTCNC_TextChanged(object sender, EventArgs e)
       int a = Convert.ToInt32(TextBoxT1234.Text);
       int b = Convert.ToInt32(TextBoxNCCDR.Text);
       TextBoxTCNC.Text = Convert.ToString(a + b); 
Kenneth Haugland 1-Nov-13 9:53am
Yes, put the code in one of the other textboxs?
Well, you designed something without much thinking and now asking to fix it. It does not work like that. Create a reasonable design taking into account bigger picture (or at least explain it) and then implement it, don't try to fix what is already wrong. This is not a worst case. Imagine that you entered non-digits, say, from clipboard. Then most changes to the text will throw an exception again and again, even if you are trying to remove a character. It's just that the whole idea is bad.
Tom Marvolo Riddle 1-Nov-13 11:07am
Not clear elaborate it.
JoCodes 3-Nov-13 6:45am
Not Clear...

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