private void btnCompute_Click(object sender, EventArgs e)
{
double width = 0;
double length = 0;
double height = 0;
if (!double.TryParse(this.tbWidth.Text.Trim(), out width))
MessageBox.Show("The width is invalid.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!double.TryParse(this.tbHeight.Text.Trim(), out height))
MessageBox.Show("The height is invalid.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (!double.TryParse(this.tbLength.Text.Trim(), out length))
MessageBox.Show("The length is invalid.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
It accepts negative numbers, but I want to able to show an error message when a negative number is entered for the width, height, or length.
Any help is greatly appreciated, Thanks!