Question: Here is my code:

```
private void textBox1_TextChanged(object sender, EventArgs e)
{
     DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
     System.Globalization.CultureInfo.InvariantCulture);

     TimeChangedHandler(myDate);
} 

```

If I delete 1 number from hours then it works fine, but if I delete both numbers e.x. I want to change from 11 to 22 then it crashes. So how do I make the form `"yyyy-MM-dd H:m:s"` work for all cases? Thanks!

Answer: 
you shouldn't expect that the value is always valid while the user is editing - just like while I'm editing code, it won't always be syntactically correct.

this code need to be placed inside try catch as you want flexible values something like this

```
private void textBox1_TextChanged(object sender, EventArgs e)
{
          try
          {
     DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",System.Globalization.CultureInfo.InvariantCulture);
     TimeChangedHandler(myDate);
          }
         catch (Exception ex)
         {}
} 

```

so, it will not explode if user enters incorrect values and consider using a DateTimePicker as a friendlier way of selecting a date and time.
Since it is on `TextChanged` event handler, you may wanna try to add, a `try...catch` handling during real time edits.

```
try
{
    DateTime myDate = DateTime.ParseExact(textBox1.Text, "yyyy-MM-dd H:m:s",
    System.Globalization.CultureInfo.InvariantCulture);

    TimeChangedHandler(myDate);
}catch( Exception ex )
{
    //Catch exception
}

```

Although a better solution would be placing it on a different event. Does the flexible edit means real time editing? If it is, changing the text from 11 to 22 during that time may cause the format to change, so the `ParseExact` would be better be placed on different event.