我正在尝试在 Report Builder 3.0 中编写一个自定义函数,该函数基本上检查多值参数中的值(它们将是 1、2 或 3)并返回“Bronze”(1)、“Silver”( 2)或“金”(3)取决于每行的最高点。所以...
Public Function BronzeSilverGold() As String
Dim bronzeFlag As Integer = 0
Dim silverFlag As Integer = 0
Dim goldFlag As Integer = 0
Dim numPledges As Integer = Report.Parameters!PledgeValues.Count()
For index As Integer = 1 To numPledges
If Report.Parameters!PledgeValues.Value(index) = 1 Then
bronzeFlag += 1
ElseIf Report.Parameters!PledgeValues.Value(index) = 2 Then
bronzeFlag += 1
silverFlag += 1
ElseIf Report.Parameters!PledgeValues.Value(index) = 3 Then
bronzeFlag += 1
silverFlag += 1
goldFlag += 1
End If
Next index
If goldFlag = numPledges Then
Return "Gold"
ElseIf silverFlag = numPledges Then
Return "Silver"
ElseIf bronzeFlag = numPledges Then
Return "Bronze"
End If
End Function
让我烦恼的是,当我运行报告时,单元格只返回#Error。问题似乎特别是“Report.Parameters!PledgeValues.Value(index)”。如果我运行这个:
Public Function BronzeSilverGold() As String
Dim bronzeFlag As Integer = 0
Dim numPledges As Integer = Report.Parameters!PledgeValues.Count()
Dim index as Integer = 0
For index = 1 To numPledges
If (Report.Parameters!PledgeValues.Value(1) = 2) Then
bronzeFlag += 1
End If
Next index
return bronzeFlag
End Function
然后它成功返回值 8(因为参数中的第一个值是 2)。如果我将第 7 行从 Report.Parameters!PledgeValues.Value(1) 更改为 Report.Parameters!PledgeValues.Value(index) 报告中的单元格将返回 #Error
No idea what I'm doing wrong - if anyone has any idea's they'd be much appreciated.