2013-03-07 77 views
0

我在我的報告下面的代碼:自定義代碼函數可以返回兩個值嗎?

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我的報告。

如何調整函數使其返回兩個變量,然後如何從報表中調用它們?

回答

0

如果您將ct聲明爲公共變量,那麼您可以在代碼中以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