Hello,
I'm trying to use a VB function in an RDLC file. The function works fine in a *.vb file, but when I move it to RDLC I get the following error
- An error occurred during local report processing.
- The definition of the report 'Main Report' is invalid.
- An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC42105] Function 'pageNumber' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.’.
The function in the RDLC is
<Code>
Function pageNumber(ByVal currentPage As Integer)
Dim groupTotal As Integer = 7
Dim modPage As Integer
Dim test As Integer = Math.DivRem(currentPage, groupTotal, modPage)
If modPage = 0 Then pageNumber = groupTotal Else pageNumber = modPage
End Function
</Code>
I've tried reducing the function to nothing but a single line that returns a constant value and I get the same error. I've also tried terminating the function with "return x" and with "Exit Function" after setting a the function name to a value.
I originally had "As Integer" on the end of the function header, but the RDLC engine said it expected an end of line, so I took it out.
I'm a C# programmer and this is my first foray into VB, I may be missing something quite obvious.
I'm using the WebForms version of ReportViewer.
Thank you for any help you can offer.
Tony Barton.