简体   繁体   English

星期几条件句不起作用

[英]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.

相关问题 外部功能中的条件不起作用 - Conditionals in external functions not working 计算时间段内的特定日期 - Count Specific Days of Week in Time Period 在列表中获取星期几,然后重新开始 - Getting days of the week in a list and then getting it to start over 日期+ 7个工作日 - date + 7 working days php函数可计算30天,但无休日或假期 - php function on counting 30 days but no end week or holiday 如何创建一个将字符串作为输入并返回 R 中星期几的向量的函数? - How to create a function that takes a character string as input and returns a vector of the days of the week in R? 使用循环过滤数据以比较R中一周中不同天的计算指标 - Filter data using a loop to compare calculated metrics for different days of week in R 使用Google脚本仅在一周的指定天中生成预定数量的日期列表,但不包括特定的日期列表 - generate list of A predetermined amount of dates in only specified days of week and excluding specific list of dates using google script 在Jaspersoft Studio中可以使用Days函数,但不能在JasperReports库中使用 - Days function working in Jaspersoft Studio but not with JasperReports library 在SQL函数中检查有效的工作日 - check for valid working days in an SQL function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM