自定义代码函数可以返回两个值吗?

时间:2013-03-07 12:45:43

标签: ssrs-2008 reporting-services

我的报告中有以下代码:

Dim suma As Decimal = New Decimal()

Public Function SumLookup(ByVal items As Object()) As Decimal
    If items Is Nothing Then
        Return Nothing
    End If

    Dim ct as Integer = New Integer()
    suma = 0
    ct = 0

    For Each item As Object In items
        suma += Convert.ToDecimal(item)
        ct += 1
    Next

    If (ct = 0) Then return 0 else return suma 
End Function

Public Function GetMyVal() as Decimal
    GetMyVal = suma 
End Function

上面的函数返回suma,我通过以下方式调用函数:

code.SumLookup(LookupSet(Fields!Claim_Currency.Value,Fields!Claim_Currency.Value,Fields!Total_Paid_Loss___LAE.Value, "dataSet"))

我想在报告中使用变量sumact

如何调整函数以使其返回两个变量,如何从报告中调用它们?

1 个答案:

答案 0 :(得分:0)

如果您将ct声明为Public变量,那么您可以在代码中将其作为Code.Variable访问。

Public ct As Integer

tb1=code.SumLookup(LookupSet(Fields!Claim_Currency.Value,Fields!Claim_Currency.Value,Fields!Total_Paid_Loss___LAE.Value, "dataSet"))

tb2=code.ct