I am trying to create a ticket counter, basically when the user clicks on the button ie. create ticket, the counter will increment by 1 until the next day the ticket counter will reset back to 0 again.

I have stored the counter in a database, so the database knows the last counter for a particular user. But how can I reset the counter back to 0, as soon as the user clicks the button the next day. I have a function called checkformidnight as follows but don't think this is the right way.

```
Private Function CreatTicketNumber(ByVal officerId As Integer) As String

    Dim counter As Integer = officer.Officer_Ticket_Counter '' from database
    If IsMidnight(Now) Then
        counter = 0
    Else
        counter = counter + 1
    End If

    Dim TicketNumber As String = counter.ToString("00")

    Return TicketNumber
End Function

Public Function IsMidnight(ByVal value As Date) As Boolean
    Return value.TimeOfDay.Ticks = 0
End Function

```