Saturday, May 28, 2011

Calendar/Time Display


Design a window that displays the current month, day, and year.  Also, display the current time, updating it every second (look into the Timer control).  Make the window look something like a calendar page.  Play with object properties to make it pretty.

My Solution:

Form:


timDisplay
 
lblTime
 
lblYear
 
lblNumber
 
lblMonth
 
lblDay
 



Properties:

Form frmCalendar:
            Caption = My Calendar
            BorderStyle = 1 - Fixed Single

Timer timDisplay:
            Interval = 1000

Label lblDay:
            Caption = Sunday
            FontName = Times New Roman
            FontBold = True
            FontSize = 24

Label lblTime:
            Caption = 00:00:00 PM
            FontName = Times New Roman
            FontBold = True
            FontSize = 24

Label lblYear:
            Alignment = 2 - Center
            Caption = 1998
            FontName = Times New Roman
            FontBold = True
            FontSize = 24

Label lblNumber:
            Alignment = 2 - Center
            Caption = 31
            FontName = Arial
            FontBold = True
            FontSize = 72

Label lblMonth:
            Alignment = 2 - Center
            Caption = March
            FontName = Times New Roman
            FontBold = True
            FontSize = 24


Code:

General Declarations:

Option Explicit


timDisplay Timer Event:

Private Sub timDisplay_Timer()
Dim Today As Variant
Today = Now
lblDay.Caption = Format(Today, "dddd")
lblMonth.Caption = Format(Today, "mmmm")
lblYear.Caption = Format(Today, "yyyy")
lblnumber.Caption = Format(Today, "d")
lblTime.Caption = Format(Today, "h:mm:ss ampm")
End Sub

No comments:

Post a Comment