On my form I have a label that shows the pc time, after 2 hours i want the form to end. But i want to run the form at different times so i cant type in the time i want it to end.
does anybody know how i go about it?
thanks in advance
Chris1990
Printable View
On my form I have a label that shows the pc time, after 2 hours i want the form to end. But i want to run the form at different times so i cant type in the time i want it to end.
does anybody know how i go about it?
thanks in advance
Chris1990
VB Code:
Dim mTime1 As Integer ' Seconds Dim mMin As Integer ' Minutes Private Sub Form_Load() Timer1.Enabled = True Timer1.Interval = 1000 Text1.Text = 120 End Sub Private Sub Timer1_Timer() mTime1 = mTime1 + 1 ' counting seconds If mTime1 > 60 Then mMin = mMin + 1: mTime1 = 0 Text2.Text = mTime1 If Text1.Text = mMin Then Print " something" End Sub
VB Code:
' Timer1.Enabled = True, .Interval = 1000 Private dEnd As Date Private Sub Form_Load() dEnd = Now + TimeSerial(2, 0, 0) End Sub Private Sub Timer1_Timer() Label1.Caption = Time If Now > dEnd Then Unload Me End Sub