I am trying to check for non numeric data however the user must be able to use decimal points, I have the following code so far but this does not allow decimal point, could someone advise how I would go about this please?
Thanks in advance.
Code:// non numeric data check int num1; bool isNumeric1 = int.TryParse(txtHeight.Text, out num1); if (isNumeric1) { } else { txtHeight.Text = (""); MessageBox.Show("Only enter numbers into\nthe Height text field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } // non numeric data check int num2; bool isNumeric2 = int.TryParse(txtWeight.Text, out num2); if (isNumeric2) { // convert and display conversion in appropriate textfield, call class to convert } else { txtWeight.Text = (""); MessageBox.Show("Only enter numbers into\nthe Weight text field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }




Reply With Quote