Dim Lb1 As WinForm.DateTimePicker
Lb1 = e.Form.Controls("日期")
Dim n,n1 As Integer
Dim d2 As Date=e.Form.Controls("日期").Value '当前日期
Dim lastD As Date = d2.AddMonths(-1) '上一个月的日期
Dim d1 As New Date(lastD.Year, lastD.Month, Date.DaysInMonth(lastD.Year,lastD.Month)) '上个月
n = d1.DayOfWeek
n1 = iif(n >0,7-n,0)
d1 =d1.Adddays(n1)
d2 =d2.Adddays(n1)
n=DateDiff("d", D1, D2)+1
n1 = -Int(-n/7)*2-iif(d2.DayOfWeek<>6,1,0)
e.Form.Controls("双休").Text = n - n1 & "天"
测试,11月份的工作日结果是22天,查看手机上的日历是20天,为什么对不上,9月10月对得上.分别是22和23天.
什么原因?