设计一个小日历程序(用VB)

2025-01-04 15:33:45
推荐回答(1个)
回答1:

Private Sub Form_Click()
Dim N As Integer
Form1.FontSize = 20
If Month(Date) < 12 Then 'N:当前月份的天数
N = CDate(Year(Date) & "-" & Month(Date) + 1 & "-1") - CDate(Year(Date) & "-" & Month(Date) & "-1")
Else
N = 31
End If
Print Tab(10); "今天是:"; Format(Date, "YYYY年M月D日")
Print
Print " 周一 周二 周三 周四 周五 周六 周日"
'Print " Mon Tue Wed Thu Fri Sat Sun"
For i = 1 To N
w = Weekday(CDate(Year(Date) & "-" & Month(Date) & "-1") + i - 1, vbMonday) - 1
Print Tab((w Mod 7) * 5 + IIf(i < 10, 3, 2)); i;

Next
End Sub