Hello all,
I am trying to make a program in visual basic 2010 where the user enters hours minutes and seconds into text boxes and then the program will count down from that until its equal to 0 when a msgbox appears and says its finished.
I was converting hour entered, minutes entered, and seconds entered all into seconds and then having a timer subtract 1 from that until its equal to 0.
But the problem I'm having is that I want to display the hours,minutes, and seconds left in a label to the user in a format of: "hours: 0 minutes: 23 seconds :42" but I cant figure out how to display it in this format.
HELP???

Some one suggested using the datatime data type but whenever I try running it I get this error message:


"A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll"

heres my source code so far:

Public Class Form1

Private Property DateTime As Date


Private Sub ButtonStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStart.Click

DateTime.AddHours(Integer.Parse(ComboBoxHours.Text))
DateTime.AddMinutes(Integer.Parse(ComboBoxMinutes.Text))
DateTime.AddSeconds(Integer.Parse(ComboBoxSeconds.Text))
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

DateTime = DateTime.AddSeconds(-1)

LabelHours.Text = DateTime.Hour
LabelMinutes.Text = DateTime.Minute
LabelSeconds.Text = DateTime.Second

If totalseconds < 1 Then
Timer1.Enabled = False
MsgBox("finished")
End If

End Sub
End Class

See if this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.