Results 1 to 14 of 14

Thread: putting a clock on to a form in vb6

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    1

    putting a clock on to a form in vb6

    please can you tell me how to put a normal clock on vb6 on my form page ???

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: putting a clock on to a form in vb6

    Moved from FAQ forum

  3. #3
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: putting a clock on to a form in vb6

    Digital or analogue clock?

    Digital
    VB Code:
    1. Private Form_Load()
    2.  
    3. 'I know the clock will count in seconds but if you have an
    4. 'Interval of 1000 then you will get a delay before it starts running
    5. Timer1.Interval = 1
    6.  
    7. End Sub
    8.  
    9. Private Sub Timer1_Timer()
    10.  
    11. Label1.Caption = Format(Time, "hh:mm:ss AM/PM")
    12.  
    13. End Sub
    The analogue clock needs a lot more code. There are loads of examples on PSC
    Last edited by Keithuk; Jan 30th, 2007 at 07:23 AM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: putting a clock on to a form in vb6


  5. #5
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: putting a clock on to a form in vb6

    Quote Originally Posted by Keithuk
    VB Code:
    1. 'I know the clock will count in seconds but if you have an
    2. 'Interval of 1000 then you will get a delay before it starts running
    3. Timer1.Interval = 1
    So you will update the clock 64 times each second, just so you won't have to wait for the clock to display? Seems like a waste. Just call the timer routine to get the clock running.
    VB Code:
    1. Timer1.Interval = 1000
    2. Timer1.Enabled = True
    3. Call Timer1_Timer

  6. #6
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: putting a clock on to a form in vb6

    Quote Originally Posted by Keithuk
    VB Code:
    1. '...
    2. 'I know the clock will count in seconds but if you have an
    3. 'Interval of 1000 then you will get a delay before it starts running
    4. '...
    You can trigger the _Timer event no mather that:
    VB Code:
    1. Private Sub Form_Load()
    2.     Timer1.Interval = 1000
    3. [B]    Timer1_Timer[/B]
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7.     Label1.Caption = Format(Time, "hh:mm:ss AM/PM")
    8. End Sub
    edit: totally missed Logophobic's post

  7. #7
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: putting a clock on to a form in vb6

    Here's a two line example...

    Khanjan
    Attached Files Attached Files
    Hey... If you found this post helpful please rate it.

  8. #8
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: putting a clock on to a form in vb6

    Quote Originally Posted by Logophobic
    Just call the timer routine to get the clock running.
    VB Code:
    1. Timer1.Interval = 1000
    2. Timer1.Enabled = True
    3. Call Timer1_Timer
    The Timer can be running before the Form loads and you still have a delay with a 1 second interval.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  9. #9
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: putting a clock on to a form in vb6

    The timer cannot be running before the form is loaded. That would be like a program running before the computer is turned on. I think what you meant is that the timer can be enabled at design-time. In any case, the initial delay can be avoided by calling the timer's timer event, as in my example.

  10. #10
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: putting a clock on to a form in vb6

    Hey hey guys... apparently misher2000 hasn't replied yet... so why are we arguing over what he wants... wait till he replies... calm down....
    btw... Welcome to the forums misher2000

    Khanjan
    Hey... If you found this post helpful please rate it.

  11. #11
    Lively Member
    Join Date
    Oct 2006
    Posts
    78

    Re: putting a clock on to a form in vb6

    put timer on the form and set the delay to 1000 then add a label to the form and...

    Private Sub Timer1_Timer()
    label1.Caption = Format(Now, "hh:mm:ss")
    End Sub

  12. #12
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: putting a clock on to a form in vb6

    dannyg... if you look at the example in post 7, thats exactly what it does
    Hey... If you found this post helpful please rate it.

  13. #13
    Lively Member
    Join Date
    Oct 2006
    Posts
    78

    Re: putting a clock on to a form in vb6

    sorry dint download it to see am at college lol

  14. #14
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: putting a clock on to a form in vb6

    Quote Originally Posted by khanjan_a2k
    dannyg... if you look at the example in post 7, thats exactly what it does
    And post #3.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

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