vb中如何获取每个月的第一天是星期几

2024-11-28 11:52:17
推荐回答(2个)
回答(1):

Sub Fweekday()

Dim Firstday As Date

For i = 1 To 12
Firstday = Year(Now) & "-" & i
Print Firstday & "是星期" & weekday(Firstday, vbMonday)
Next

End Sub

回答(2):

用weekday函数。
print weekday("2009-5-1")-1 'weekday返回的数比正常多一。
也可以用变量:
r="2009"
s="5"
print weekday(r & "-" & s & "-1")-1