Results 1 to 3 of 3

Thread: [RESOLVED] Date Change

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    49

    Resolved [RESOLVED] Date Change

    I am trying to recognize a change in date from todays. Basically, when the date changes at midnight or 12:01...(whatever it is on the pc). Here is what I have so far...this is not working though, the message box pops up immediately. Thanks in advance
    VB Code:
    1. Private Sub Timer1_Timer()
    2.     Static smi_date As Integer
    3.    
    4.     If smi_date <> Day(Now) Then
    5.         MsgBox ("Hello, New Day")
    6.         smi_date = Day(Now)
    7.     End If
    8. End Sub

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Date Change

    The first time the timer is triggered, the variable has value 0, so it has a different value then the current day.

    VB Code:
    1. Private Sub Timer1_Timer()
    2.     Static smi_date As Integer
    3.     If smi_date = 0 Then smi_date = Day(Now)
    4.    
    5.     If smi_date <> Day(Now) Then
    6.         MsgBox ("Hello, New Day")
    7.         smi_date = Day(Now)
    8.     End If
    9. End Sub
    Frans

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    49

    Re: Date Change

    That would make sense, I forgot it isn't inititalized...Thank you Frans!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width