[英]Days of Week Conditionals not working
I am trying to obtain a due date based from the date and time of the system. 我正在尝试根据系统的日期和时间获取截止日期。 Obtaining the due date is straight forward, but getting the label to change is just not working.
获取截止日期很简单,但是更改标签只是行不通的。 The result I get is usually today's date.
我得到的结果通常是今天的日期。
Public Function FindDueDate()
Dim Due As Date = Now
If DayOfWeek.Monday Then
DueDate.Text = Due.AddDays(14).ToString
ElseIf DayOfWeek.Tuesday Then
DueDate.Text = Due.AddDays(13).ToString
ElseIf DayOfWeek.Wednesday And Hour(Now) < 16 Then
DueDate.Text = Due.AddDays(12).ToString
ElseIf DayOfWeek.Wednesday And Hour(Now) >= 16 Then
DueDate.Text = Due.AddDays(19).ToString
ElseIf DayOfWeek.Thursday Then
DueDate.Text = Due.AddDays(18).ToString
ElseIf DayOfWeek.Friday Then
DueDate.Text = Due.AddDays(17).ToString
ElseIf DayOfWeek.Saturday Then
DueDate.Text = Due.AddDays(16).ToString
ElseIf DayOfWeek.Sunday Then
DueDate.Text = Due.AddDays(15).ToString
End If
End Function
What am I doing wrong? 我究竟做错了什么?
I think what you're trying to do is: 我认为您要执行的操作是:
Public Function FindDueDate()
Dim Due As Date = Now
If Due.DayOfWeek = DayOfWeek.Monday Then
DueDate.Text = Due.AddDays(14).ToString
ElseIf Due.DayOfWeek = DayOfWeek.Tuesday Then
...
End If
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.