title: How to check whether the entered date is in the correct format?
body: <p>I have a textbox where a user is supposed to enter a date. How can I check whether the entered date is in the correct date format? </p>
  
  <blockquote>
    <p>Like this: <code>02/02/2008</code></p>
  </blockquote>
  
  <ul>
  <li>not like this <code>022/22/-1</code></li>
  <li>not like this <code>2009/02/02</code></li>
  <li>not like this <code>02/Jun/2015</code></li>
  <li>not like this <code>02/abc/2010</code></li>
  </ul>
  
  <p>(I don't want to use DateTimePicker or MonthCalender).</p>
  
  <p>EDIT 1</p>
  
  <p>I tried it like this </p>
  
  <pre><code>Private Sub txtHireDate_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtHireDate.Validated
      Dim dateString As String = txtHireDate.Text
      Dim formats As String = "MM/dd/yyyy"
      Dim dateValue As DateTime
  
      If DateTime.TryParseExact(dateString, formats, New CultureInfo("en-US"), DateTimeStyles.None, dateValue) Then
  
      End If
  </code></pre>
  
  <p>But its showing some errors </p>
  
  <p><img src="https://i.stack.imgur.com/Wh61A.png" alt="enter image description here"></p>