There are two problems:
1) In the If statement, the And should be Or.
2) Even if you change the Format property of the DateTimePicker to Time, the datetimepicker still stores the date. Therefore, the If statement is comparing 5:00 PM and 10:01 PM to, in my case 10/3/2008 6:00 PM. Because of the date part of the datetimepicker, the value in the date timepicker will always be larger than 10:01 PM.
Here is some code I put together to overcome these two issues:
Dim time559 As DateTime
Dim time1001 As DateTime
Dim time1 As DateTime
time559 = FormatDateTime("5:00:00 PM", DateFormat.LongTime)
time1001 = FormatDateTime("10:01:00 PM", DateFormat.LongTime)
time1 = FormatDateTime(Hour(btime1.Value) & ":" & Minute(btime1.Value))
If time1 < time559 Or time1 > time1001 Then
MsgBox("Booking Time is only available from 6.00 PM to 10.00 PM ")
Else
MsgBox("OK ")
End If
Let me know if that works.