Zac*_*ner 2 vb.net sql-server-2008-r2 reporting-services
我正在尝试为我的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
Run Code Online (Sandbox Code Playgroud)
传递给此函数的参数是我的数据集中的可空日期(SQL Server日期类型),我从TextBox的BackgroundColor属性调用该函数:
=Code.SetBoxColor(Fields!dateOne.Value, Fields!dateTwo.Value, Fields!dateThree.Value)
Run Code Online (Sandbox Code Playgroud)
运行该函数将返回错误:
'is'需要具有引用类型的操作数,但此操作数的值类型为"Date".
任何帮助,将不胜感激.