I post a question i have one field loan in that i have to type only numbers not characters
I post a question i have one field loan in that i have to type only numbers not characters.
Loan 1000.
you posted answers as follows
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
}
in that i click a loan text box
private void txt_loan_TextChanged(object sender, EventArgs e)
only text changed only there.not key press event.
what to do.
above one i am creating in vb.net using csharp. it is a window application.help me wat to do.
private void txt_others_TextChanged(object sender, EventArgs e)
{
int a, b, c, d;
if (!int.TryParse(txt_gross.Text, out a) || a < 0)
{
MessageBox.Show("Not a valid number. Please reenter.");
txt_gross.Focus();
return;
}
if (!int.TryParse(txt_totdeductions.Text, out b) || b < 0)
{
MessageBox.Show("Not a valid number. Please reenter.");
txt_totdeductions.Focus();
return;
}
if (!int.TryParse(txt_others.Text, out c) || c < 0)
{
MessageBox.Show("Not a valid number. Please reenter.");
txt_others.Focus();
return;
}
d = a - b + c;
txt_totpayable.Text = d.ToString();
}
in that onlytext changed only there.not key press event.how to do.please send the code.urgent.
Regards,
Narasiman P