效果图
Dim mDate As Date
Private Sub Command1_Click(Index As Integer)
If Index = 0 Then mDate = DateAdd(\ If Index = 1 Then mDate = DateAdd(\ LoadDayCaption End Sub
Private Sub Form_Load() mDate = Now
Label2(0).Left = Label1(0).Left
Label2(0).Top = Label1(0).Top + Label1(0).Height + 100 LoadWeekLabel LoadDayLabel LoadDayCaption End Sub
Private Function LoadWeekLabel() Dim i As Integer For i = 1 To 6
Load Label1(i)
Label1(i).Visible = True
Label1(i).Left = Label1(i - 1).Left + Label1(i - 1).Width + 10 Next
Label1(0).Caption = \星期日\ Label1(1).Caption = \星期一\
Label1(2).Caption = \星期二\ Label1(3).Caption = \星期三\ Label1(4).Caption = \星期四\ Label1(5).Caption = \星期五\ Label1(6).Caption = \星期六\End Function
Private Function LoadDayLabel() Dim i As Integer For i = 1 To 41
Load Label2(i)
Label2(i).Visible = True
Label2(i).Left = Label1(i Mod 7).Left If i > 6 Then
Label2(i).Top = Label2(i - 7).Top + Label2(i - 7).Height + 10 End If Next End Function
Private Function LoadDayCaption()
Label3.Caption = Format(mDate, \
Dim i As Integer, Index As Integer
Dim fistWeekDay As Integer, days As Integer, tempDate As Date fistWeekDay = Weekday(DateAdd(\
tempDate = DateAdd(\ tempDate = DateAdd(\ tempDate = DateAdd(\ days = Day(tempDate) For i = 0 To 41
Label2(i).Caption = i - fistWeekDay
Label2(i).Visible = (i - fistWeekDay) > 0 And (i - fistWeekDay) <= days Next End Function