1、效果图Dim mDate As DatePrivate Sub Command1_Click(Index As Integer)If Index = 0 Then mDate = DateAdd(“M“, -1, mDate)If Index = 1 Then mDate = DateAdd(“M“, 1, mDate)LoadDayCaptionEnd SubPrivate Sub Form_Load()mDate = NowLabel2(0).Left = Label1(0).LeftLabel2(0).Top = Label1(0).Top + Label1(0).Height + 10
2、0LoadWeekLabelLoadDayLabelLoadDayCaptionEnd SubPrivate Function LoadWeekLabel()Dim i As IntegerFor i = 1 To 6Load Label1(i)Label1(i).Visible = TrueLabel1(i).Left = Label1(i - 1).Left + Label1(i - 1).Width + 10NextLabel1(0).Caption = “星期日“Label1(1).Caption = “星期一“Label1(2).Caption = “星期二“Label1(3).Ca
3、ption = “星期三“Label1(4).Caption = “星期四“Label1(5).Caption = “星期五“Label1(6).Caption = “星期六“End FunctionPrivate Function LoadDayLabel()Dim i As IntegerFor i = 1 To 41Load Label2(i)Label2(i).Visible = TrueLabel2(i).Left = Label1(i Mod 7).LeftIf i 6 ThenLabel2(i).Top = Label2(i - 7).Top + Label2(i - 7).He
4、ight + 10End IfNextEnd FunctionPrivate Function LoadDayCaption()Label3.Caption = Format(mDate, “YYYY-MM“)Dim i As Integer, Index As IntegerDim fistWeekDay As Integer, days As Integer, tempDate As DatefistWeekDay = Weekday(DateAdd(“d“, 1 - Day(mDate), mDate) - 2tempDate = DateAdd(“d“, 1 - Day(mDate), mDate)tempDate = DateAdd(“M“, 1, tempDate)tempDate = DateAdd(“d“, -1, tempDate)days = Day(tempDate)For i = 0 To 41Label2(i).Caption = i - fistWeekDayLabel2(i).Visible = (i - fistWeekDay) 0 And (i - fistWeekDay) = daysNextEnd Function