private button_click() { if ( textbox.text ! = integer) //something like that { MessageBox.Show("enter a valid number"); textbox.Text.clear(); << get the input from user again using the same textbox and request the user to click the button again } else { newCar.cylinders = double.Parse(textBox.Text); } }
int value; if (Int32.TryParse(textBox.Text, out value)) { // do something } else { // show error }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)