0

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???

2
Contributors
2
Replies
13
Views
6 Years
Discussion Span
Last Post by codeorder
1

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

Edited by shredder2794: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.