Progressive Clock

Introduction

In this example, we will display the current time of the computer using progress bars. A dialog box will be equipped with these controls that each receives its value from the computer and displays the value graphically.

  1. Start Microsoft Access and create a blank database
  2. Save the database as Progress Clock
  3. Start a new form in Design View. Save it as ProgressClock
  4. To use the needed progress bars, on the Toolbox, click the More Controls button
  5. From the list, click Microsoft Progress Bar Control, Version 6.0 and click somewhere on the form
  6. Right-click the progress bar in the form and click Copy. Then right-click the form twice and click Paste twice
  7. Design the form as follows:
     
    Control Properties
    Form Caption: Progressive Clock
    Navigation Buttons: No
    Modal: Yes
    Border Style: Dialog
    Timer Interval: 20
    Label Caption: Time
       
    Label Caption: Hours:
    Progress Bar Name: prgHours
    Max: 23
    TextBox Name: txtHours
    Text Align: Center
    Label Caption: Minutes:
    Progress Bar Name: pgrMinutes
    Max: 59
    TextBox Name: txtMinutes
    Text Align: Center
    Label Caption: Seconds:
    Progress Bar Name: pgrSeconds
    Max: 59
    TextBox Name: txtSeconds
    Text Align: Center
  8. Double-click the selection button of the form . In the Properties window, click the Events tab. Access the On Timer event of the form and implement it as follows:
     
    Private Sub Timer1_Timer()
        Dim CurTime As Date
        Dim ValHours As Integer
        Dim ValMinutes As Integer
        Dim ValSeconds As Integer
        
        CurTime = Time
        ValHours = Hour(CurTime)
        ValMinutes = Minute(CurTime)
        ValSeconds = Second(CurTime)
        
        pgrHours.Value = ValHours
        pgrMinutes.Value = ValMinutes
        pgrSeconds.Value = ValSeconds
        
        lblHours.Caption = CStr(ValHours)
        lblMinutes.Caption = ValMinutes
        lblSeconds.Caption = CStr(ValSeconds)
    End Sub
  9. Test the application
 

Home Copyright © 2004-2014 FunctionX, Inc.