I'm stuck on this one too! The following code has two timers. Timer two works fine it outputs to the debug line every 30 seconds. Timer one seems to work it sets the time in the label and it changes every second. However the debug.writeline does not output. The debug writeline does output from the if then loop.
The code is intended to set the variable today and yesterday. When it runs past 12:00 it sets yester to 070619 yet the clock on the computer is the 5th day. I cannot figure out where the 7th is coming from.
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim noon As Boolean
Dim CurrentTime As String
Dim yesterday As String = ""
Dim yester As String
Dim today As String
If yester = "" Then
yester = "040619"
End If
If today = "" Then
today = "050619"
End If
Debug.WriteLine(today & "T")
If CurrentTime > 12000 Or CurrentTime < 1200 Then
noon = False
End If
CurrentTime = Date.Now.ToString("hhmmss")
If today = Date.Now.ToString("ddMMyy") Then
noon = True
End If
If noon = False And CurrentTime = "120000" Then
yester = today
today = Date.Now.ToString("ddMMyy")
Debug.WriteLine(yester & "y")
Debug.WriteLine(today & "T")
End If
Debug.WriteLine(CurrentTime)
Label2.Text = Date.Now.ToString("dd-MM-yy hh:mm:ss")
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Debug.WriteLine("timed out")
End Sub
End Class
HELP!
Dave