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);
return;
}
if (!double.TryParse(this.tbLength.Text.Trim(), out length))
{
MessageBox.Show("The length is invalid.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
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!

Faraz khan2 reputationPosted Dec 9, 2012, 12:51 AM EST
if (_value 0) { MessageBox.Show("The _value is invalid.", "Notification",MessageBoxButtons.OK, MessageBoxIcon.Error); return; }VulpesRank #55 · 29.2K reputationPosted Dec 9, 2012, 5:42 AM EST