I have attached one code of my project and i need a help in that.
The code is running without any error but i am stuck up in modifying that how to make a statement, of invalid format of date or time if the user enters the wrong format should i use Try Catch blocks or simply use the if else statement
I need to make it quite simple.

Recommended Answers

Hi, sam wage, welcome here at DaniWeb.
I'm in with grarhakim here. If you can avoid it, don't annoy users with error messages and exceptions, just because the poor user typed something wrong in a date.

Jump to Post

All 3 Replies

If you r using winforms, why don't you use the datetimepicker control?
WPF DatePicker Control??

Hi, sam wage, welcome here at DaniWeb.
I'm in with grarhakim here. If you can avoid it, don't annoy users with error messages and exceptions, just because the poor user typed something wrong in a date.

You could use the TryParseExact method explained here Click Here

The easiest solution would however be just using the dateTimePicker as mentioned by grarhakim.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.