Custom Code

  • Help. Getting the following error

    There is an error on line 0 of custom code: [BC30213] Comma or ')' expected.

    Here is the custom code

    Public Function CalcPercent(totals as double , fldValue as double ) as double

    dim retVal as double

    if totals = 0 then

       retVal = 0

    else

       retVal =  fldvalue / totals

    end if

    return retVal

    End Function

    Here is the call

    =code.CalcPercent( Fields!lyTotals.Value , Fields!Video.Value - Fields!lyVideo.Value )

  • I'm not an expert, but your code might work better like this:

    ALTER Function CalcPercent(@totals as double , @fldValue as double )

    RETURNS double AS

    Begin

    dim @retVal as double

    if @totals = 0 then

       @retVal = 0

    else

       @retVal =  @fldvalue / @totals

    end --if

    return @retVal

    End --Function

    Hope this helps.


    Butch

  • ur code looks fine

    try adding ( ) 

    =code.CalcPercent(Fields!lyTotals.Value , (Fields!Video.Value - Fields!lyVideo.Value))

    do let us know if this works or u hv found out the solution

    thanks

     

  • The following worked. The only difference that I see is that I removed the blank line before the body of the function.??

    Thanks for the assistance.

    Public Function CalcPercent(totals as double, fldValue as double) as double

    dim retVal as double

    if totals = 0 then

       retVal = 0

    else

       retVal =  fldvalue / totals

    end if

    return retVal

    End Function

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply