N
nautonnier
Hello All,
I'm validating a textbox to make sure it contains only a whole number
so I'm using Int32.TryParse. It works fine when I test it on a local
winform app. However, when I transfer the code to my project that's
using ClickOnce, it throws an error.
Here's the code that's identical in both projects:
int parseResult;
if (Int32.TryParse(txtNumberTest.Text, out parseResult))
{
if (parseResult <= 0)
{
isValid = false;
errorMessage += "Textbox must be a number error message\n";
}
}
The error is follows:
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDouble(String value, NumberStyles options,
NumberFormatInfo numfmt)
at System.Double.Parse(String s, NumberStyles style,
NumberFormatInfo info)
at System.Convert.ToDouble(String value)
at myClickOnceApp.frmMain.checkForm()
at myClickOnceApp.frmMain.btnSave_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
Any ideas would be appreciated.
I'm validating a textbox to make sure it contains only a whole number
so I'm using Int32.TryParse. It works fine when I test it on a local
winform app. However, when I transfer the code to my project that's
using ClickOnce, it throws an error.
Here's the code that's identical in both projects:
int parseResult;
if (Int32.TryParse(txtNumberTest.Text, out parseResult))
{
if (parseResult <= 0)
{
isValid = false;
errorMessage += "Textbox must be a number error message\n";
}
}
The error is follows:
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDouble(String value, NumberStyles options,
NumberFormatInfo numfmt)
at System.Double.Parse(String s, NumberStyles style,
NumberFormatInfo info)
at System.Convert.ToDouble(String value)
at myClickOnceApp.frmMain.checkForm()
at myClickOnceApp.frmMain.btnSave_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
Any ideas would be appreciated.