If you get this exception of the first line of code, you'll have to make sure that the content of txtHeadlinedate
is valid and parse it accordingly.
If the error comes from the call to TimeSpan.Parse
, the following version should fix the problem:
DateTime date = Convert.ToDateTime(txtHeadlinedate.Text.Trim(), Ci);
Headlinedate = date.Add(DateTime.Now.TimeOfDay);