This is what I ended up with
Code:
private void tXPos_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
XPos = double.Parse(tXPos.Text);
}
catch(FormatException)
{
tXPos.Text = XPos.ToString();
MessageBox.Show("X Input is not a valid number", "Invalid input in X", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch(OverflowException)
{
tXPos.Text = XPos.ToString();
MessageBox.Show("X Input is out of range", "Invalid input in X", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch(Exception ex)
{
tXPos.Text = XPos.ToString();
MessageBox.Show("" + ex, "Invalid input in X", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
One of the biggest reason I prefere C# is because the catch try system for all error handling.