Windows Develop Bookmark and Share   
 index > Windows Forms General > Check if TextBox contents are Numeric
 

Check if TextBox contents are Numeric

I have a text box which will contain numbers (mobile numbers) and these will be delimited by comma's as shown below: -

07845123123, 07845321321, 07845123456

When the user clicks on a button I want to check that the contents of the textbox only contains numbers and comma's and doesn't start with a comma.

What wouldpeople recommend as the best way to handle this type of validation?

Thanks & Regards

Mirific1  Monday, June 26, 2006 9:49 AM

As the numbers are too big for int.TryParse, I'd say you want to write a KeyPress event handler that sets Handled to true if Char.IsControl and Char.IsDigit are false, and the character typed is not a ,.

cgraus  Monday, June 26, 2006 10:06 AM

As the numbers are too big for int.TryParse, I'd say you want to write a KeyPress event handler that sets Handled to true if Char.IsControl and Char.IsDigit are false, and the character typed is not a ,.

cgraus  Monday, June 26, 2006 10:06 AM

You can use google to search for other answers

Custom Search

More Threads

• Flickering inside user control.
• Datagridview - reorder columns after scroll
• ToolstripRenderer in whidbey colors
• Edit list view
• How to Refresh the old form from current form?
• How to retrieve the LV_ITEM's info by SendMessage
• Use of Rich Text Box
• localization and resource files
• How to do query if a property/method is supported by the object?
• Installation of Windows service