ابتدا مشخصات فايل را تعريف ميکنيم:
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
حالا کد برنامه:
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
توضيح اضافه:
timDispl يک تايمر است.