Firstly - aren't first chance exceptions specific to the debugger?
Secondly - a better approach is to avoid the exception at all;
int value;
if(int.TryParse(text, out value)) {
// do something useful with value
} else {
MessageBox.Show("Whoops");
}
Marc
"Jack jensen" <Ja*********@mail.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,
I have the code below :(simplified zip code format)
try
{
Convert.ToInt32(tbOShipPostalCode.Text);
}
catch
{
MessageBox.Show("The zip code must be a number.", "Zip code error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
The user should only see the messagebox when the input is not a number.
But they see message as if the exception was not beeing handled.
"
A first chance exception of type 'System.FormatException' occurred in
mscorlib.dll
Additional information: Input string was not in a correct format.
"
How can i avoid this message?
Many thanks in advance
JJ