I want to be able to check if a text box is empty
, show a message if it is, otherwise it should continue to the else code.
When i run the program and try to convert when nothing is in the text box, it skips the message and goes straight to an error "Input string was not in a correct format."
I have noted where the program stops. I figure its because the empty text box isnt a double. It seems to disregard the empty textbox message. I hope i am not in over my head here.
private void btnLengthConvert_Click(object sender, EventArgs e)
//check if textbox is empty
if (tbxLengthToConvert == null)
//check if the centimetre radio button is checked and then run the math
if (rbCM.Checked == true)
double length = double.Parse(tbxLengthToConvert.Text); ERROR
double mm = length * 10;
double cm = length * 1;
double mt = length * 0.01;
double km = length * 0.00001;
double inches = length * 2.54;
double feet = length * 0.032808399;
tbxLenMm.Text = mm.ToString();
tbxLenCm.Text = cm.ToString();
tbxLenMetres.Text = mt.ToString();
tbxLenKm.Text = km.ToString();
tbxLenIn.Text = inches.ToString();
tbxLenFt.Text = feet.ToString();