Finding out if keyed in text is numeric:
//works only for whole numbers
int intDummy;
if (Int32.TryParse(string, out intDummy) {
//text is numeric
} else {
//text is not numeric
}
//this one works for decimals
try {
Decimal cValue = Convert.ToDecimal(stringText);
//bla bla bla...
} catch (Exception exc) {
errorText = "invalid non-numeric value. ";
}
//works only for whole numbers
int intDummy;
if (Int32.TryParse(string, out intDummy) {
//text is numeric
} else {
//text is not numeric
}
//this one works for decimals
try {
Decimal cValue = Convert.ToDecimal(stringText);
//bla bla bla...
} catch (Exception exc) {
errorText = "invalid non-numeric value. ";
}