I was trying to edit this countdown timer code but it returns ans error maybe somebody can figure this out. It is a simple countdown you select a date and time and it counts back to that date ant time. The error Conversation from string to date is not valid.
Public Class Form1
Dim atgal As Date
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
atgal = FormatDateTime(Me.DateTimePicker1.Text & " " & _
Me.DateTimePicker2.Text, DateFormat.GeneralDate) This part returns the error
Me.Timer2.Enabled = True
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim sena As Date = Date.Now
Dim nauja As Date = atgal
Dim skirtumas As TimeSpan = sena.Subtract(nauja)
Me.Label3.Text = "Days" & skirtumas.Days & "Time" & skirtumas.Hours & ":" & skirtumas.Minutes & ":" & skirtumas.Seconds
If skirtumas.Days = 0 And skirtumas.Hours = 0 And skirtumas.Minutes = 0 And skirtumas.Seconds = 0 Then
Me.Timer1.Enabled = False
MessageBox.Show("Session reached", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Label3.Text = "Days 0 Time 00:00:00"
Me.Timer1.Enabled = False
End Sub
End Class
Public Class Form1
Dim atgal As Date
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
atgal = FormatDateTime(Me.DateTimePicker1.Text & " " & _
Me.DateTimePicker2.Text, DateFormat.GeneralDate) This part returns the error
Me.Timer2.Enabled = True
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim sena As Date = Date.Now
Dim nauja As Date = atgal
Dim skirtumas As TimeSpan = sena.Subtract(nauja)
Me.Label3.Text = "Days" & skirtumas.Days & "Time" & skirtumas.Hours & ":" & skirtumas.Minutes & ":" & skirtumas.Seconds
If skirtumas.Days = 0 And skirtumas.Hours = 0 And skirtumas.Minutes = 0 And skirtumas.Seconds = 0 Then
Me.Timer1.Enabled = False
MessageBox.Show("Session reached", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Label3.Text = "Days 0 Time 00:00:00"
Me.Timer1.Enabled = False
End Sub
End Class