title: VB Validation if Date Falls between Range
body: <p>I am wondering if some one might be able to assist me with my VB code.  I believe I am close, because a lot of the time my code works just fine but I noticed that there might be a weakness to it because at times I get unexpected results.  I am thinking I am missing something pretty basic here so bear with me!</p>
  
  <p>Basically, I am trying to create a simple hotel reservation system in a Data Table for a VB project that I created just playing around in my spare time.  </p>
  
  <p>What I hope to be able to accomplish is for a user to be able to select a room number from a list box then pick an arrival and departure date.  After this happens and they click a button I want the program to be able to compare the Room Number along with the beginning date of the reservation and the end date of the reservation with the room number, beginning Dates and end dates in each row already inside of the Data Table.  Anyway, here is basically how my If Statement is structured so far:</p>
  
  <pre><code>For Each data As DataRow In dtRoomReserveData.Rows
       If data.Item("RoomNum").ToString.Contains(lstSelectRoomNum.Text) AndAlso data.Item("DateArrive") &gt;= dateArrive.Value.Date AndAlso dr2.Item("DateArrive") &lt;= dateLeave.Value.Date Then
           'if there is a reservation in room exists during that Date range display error message to user:
           MessageBox.Show("Sorry!  That room is already reserved during that date range!")
           Exit Sub
       End If
  Next
  </code></pre>
  
  <p>Any help offered is greatly appreciated!</p>