Hello,
I am kind of new with vb6 and vb8. I am working on a program that has a countdown timer.
I have the code for the countdown but what I would like to do is to have it when the the countdown is done then the program will shut down. If any one can help please post somthing that is useful to me.

This is the curent code I have:

Private Sub Form_Load()
  Timer1.Interval = 1000
     Label2.Caption = "60"
End Sub

Private Sub Timer1_Timer()
     If Label2.Caption = 0 Then
          Timer1.Enabled = False
          MsgBox ("60 secs is up, looks like your out of luck")
     Else
          Label2.Caption = Label2.Caption - 1
     End If
End Sub

Recommended Answers

All 3 Replies

so...what do you want?
If u want to terminated application just add End statement.

Private Sub Timer1_Timer()
If Label2.Caption = 0 Then
    Timer1.Enabled = False
    MsgBox ("60 secs is up, looks like your out of luck")
    End
Else
    Label2.Caption = Label2.Caption - 1
End If
End Sub

Please Tell Complete Time Not Only Seconds
00:01:00 - 00:00:59

its safer to use the VAL() Function

Private Sub Form_Load()  
      Timer1.Interval = 1000     
      Label2.Caption = "60"
End Sub 

Private Sub Timer1_Timer()     
     If [B]Val[/B](Label2.Caption) = 0 Then          
            Timer1.Enabled = False
            MsgBox ("60 secs is up, looks like your out of luck")
            End
     Else          
            Label2.Caption = [B]Val[/B](Label2.Caption) - 1     
     End If
End Sub
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.