Professional Documents
Culture Documents
// funcin necesaria public static bool EsNumero(string num) { Regex patron = new Regex(@"^(\d|-)?(\d|,)*\.?\d*$"); return patron.IsMatch(num); }
// ponga el cdigo en un textbox private void textBox2_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (EsNumero(textBox2.Text)) { MessageBox.Show("Todo Bien"); } else MessageBox.Show("Solo se aceptan nmeros"); } }
Oct, 2013