Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Forms: Create a clock on a form

Author(s)
Dev Ashish

   To put a simple text clock on a form,  create a Label called lblClock on the form, set the form's TimerInterval to 1000, and the following code behind the Timer Event.

    You can also create two command buttons called cmdClockStart and cmdClockEnd and attach respective code to each to have the clock run on demand.

'***************** Code Start ***************
Private Sub Form_Timer()
    Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
End Sub

Private Sub cmdClockStart_Click()
    Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
    Me.TimerInterval = 0
End Sub
'***************** Code End ***************

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer