Results 1 to 3 of 3

Thread: Time

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Location
    Vb Forums
    Posts
    226

    Time

    Ok I dont know if you use a timer or what not but in a label I want the time to count up. When Command button 1 is clicked it will start the time until it is stopped. So starting at 0 hours, 0 minutes, 0 seconds I want it to go up until it is stopped... So how would I do something like this? Well please reply with some feedback as its very much appreciated and happ v-day everyone
    Thanks For The Help Guys

  2. #2
    Lively Member
    Join Date
    Apr 2001
    Posts
    64
    You can use a timer control......

    Add one to your form, then set it's interval to 1000, and enabled to false

    VB Code:
    1. Private Sub Command1_Click()
    2. If Timer1.Enabled = True Then
    3.     Timer1.Enabled = False
    4.     Exit Sub
    5. End If
    6.  
    7. Label1.Caption = "00:00:00"
    8. Timer1.Enabled = True
    9.  
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13.      Label1.Caption = DateAdd("s", 1, Label1.Caption)
    14.      Label1.Caption = Format(Label1.Caption, "hh:mm:ss")
    15.      Label1.Refresh
    16.  
    17. End Sub
    Last edited by bbressler; Feb 14th, 2003 at 03:22 PM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Location
    Vb Forums
    Posts
    226
    Originally posted by bbressler
    You can use a timer control......

    Add one to your form, then set it's interval to 1000, and enabled to false

    VB Code:
    1. Private Sub Command1_Click()
    2. If Timer1.Enabled = True Then
    3.     Timer1.Enabled = False
    4.     Exit Sub
    5. End If
    6.  
    7. Label1.Caption = "00:00:00"
    8. Timer1.Enabled = True
    9.  
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13.      Label1.Caption = DateAdd("s", 1, Label1.Caption)
    14.      Label1.Caption = Format(Label1.Caption, "hh:mm:ss")
    15.      Label1.Refresh
    16.  
    17. End Sub
    Lol wow damn fast and very well explained bro thanks very much I appreciate it a lot happ v-day
    Thanks For The Help Guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width