用户可以在表单中选择开始日和结束日. (比如星期一到星期一.)
如何检查当前工作日是否在这两个工作日之间?
Dim WEstart As DayOfWeek = 5 'Friday
Dim WEend As DayOfWeek = 1 'Monday
If Date.Now.DayOfWeek >= WEstart And Date.Now.DayOfWeek <= WEend Then
Return True
Else
Return False
End If
不行.
最佳答案 试试看.这将检查星期五和星期一之间的天数.也就是说,它在周五,周六,周日和周一返回“真”.
如果星期几是星期二,星期三或星期四,则返回false.
Dim startday As DayOfWeek = DayOfWeek.Friday
Dim endday As DayOfWeek = DayOfWeek.Sunday
Dim today As DayOfWeek = DateTime.Now.DayOfWeek
If endday >= startday Then
Return (today >= startday AndAlso today <= endday)
Else
Return (today >= startday OrElse today <= endday)
End If