gpt4 book ai didi

vb.net - 检查自定义代码函数中的 NULL 日期

转载 作者:行者123 更新时间:2023-12-02 06:58:18 31 4
gpt4 key购买 nike

我正在尝试为 SSRS 报告实现一个函数,该函数将根据三个日期的值返回颜色值:

Function SetBoxColor(dateOne As Date, dateTwo As Date, dateThree As Date) As String
' Determine colors for text box
If (dateOne Is Nothing) Then
SetBoxColor = "Blue"
Else
If (dateThree Is Nothing) Then
If dateOne >= Date.Now Then
If DateDiff("d",dateOne,Date.Now) < 90
SetBoxColor = "Yellow"
Else
SetBoxColor = "White"
End If
Else
SetBoxColor = "Orange"
End If
Else
If dateThree <= dateOne Or (Month(dateThree) = Month(dateOne) And Year(dateThree) = Year(dateOne)) Then
SetBoxColor = "Green"
Else
SetBoxColor = "Red"
End If
End If
End If
Return SetBoxColor
End Function

传递给此函数的参数是我的数据集中的可为空日期(SQL Server 日期类型),我从 TextBox 的 BackgroundColor 属性调用该函数,如下所示:

=Code.SetBoxColor(Fields!dateOne.Value, Fields!dateTwo.Value, Fields!dateThree.Value)

按原样运行该函数会返回错误:

'Is' requires operands that have reference types, but this operand has the value type 'Date'.

如有任何帮助,我们将不胜感激。

最佳答案

您尝试过dateOne = Nothing吗?

关于vb.net - 检查自定义代码函数中的 NULL 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9184745/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com