private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar))
{
stemp += e.KeyChar.ToString();
double.TryParse(stemp, out tempararymain);
}
else if (e.KeyChar == Convert.ToChar(Keys.Back) || e.KeyChar == Convert.ToChar(Keys.Delete) || e.KeyChar == Convert.ToChar(Keys.Enter))
{
if (textBox1.Text.Length > 0)
{
stemp = textBox1.Text.Substring(0, textBox1.Text.Length-1);
double.TryParse(stemp, out tempararymain);
}
}
else if (e.KeyChar.ToString() == ".")
{
stemp = textBox1.Text + e.KeyChar.ToString();
double.TryParse(stemp, out tempararymain);
}
else
{
e.Handled = true;
}
}
The above code is working only for bakspace. i try to delete the text from text box by selecting previous data and want to enter another data but at time of exeution that previous data which i previously entered also come along with new data. what can i do???
in attaced file first i enter 1 and execute it. it shows right answer.
then i select that that 1 and using delet button i delete it and wirte 5 and again execute it
but at this time the answer apper as shown in fig

New Topic/Question
Reply



MultiQuote





|