I don't know if this might be helpful to anyone but I struggled with the logic for quite sometime. I needed code to change skins from day to night or from night to day depending on when my app considered day or night.
This code was added to a timer which already kept trac of the system time for other reasons.
Code:
'gui.day = 6:00 AM
'gui.night = 5:45 PM
'*
'* Check to see if current time falls between 6AM and 5:45PM or 5:45PM and 6AM
'*
If buffer.Compare(System.DateTime.Now.TimeOfDay, gui.night.TimeOfDay) = 1 Or buffer.Compare(System.DateTime.Now.TimeOfDay, gui.day.TimeOfDay) = -1 Then
'*
'* Ok we're in night so lets see if we really need to change the skin over
'*
If Not gui.current_skin = "nightSKIN" Then
'*
'* Looks like we're going to have to change the skin, call the sub
'*
gui.change_skin("night")
End If
Else
'*
'* Hmm, must be the morning, boy that night flew by!
'*
'*
'* Check to see if we need to change the skin to day
'*
If Not gui.current_skin = "daySKIN" Then
'*
'* Change skin over to day time
'*
gui.change_skin("day")
End If
End If