private void txtNum1_KeyPress(object sender, KeyPressEventArgs e) { if (!(e.KeyChar <= '' && e.KeyChar >= '') && e.KeyChar != '\r' && e.KeyChar != '\b') { e.Handled = true; } }