none
Calling a function in custom code from another function RRS feed

  • Question

  • I have code similar to the following in a report's custom code block in a VB 2005 project:


    Function DoFormat(ByVal number As Double) As String
    ...do something to format the number...
         Return formattedNumber
    End Function
     
    Function GetField(ByVal recordType as Integer, ByVal number As Double)
        Select Case recordType
            Case 1
                Return Code.DoFormat(number) & " something"
            Case 2
                Return Code.DoFormat(number) & " something else"
    ....
        End Select
    End Function


    When I attempt to build the solution, I get the following error:

    "There is an error on line xx of custom code: [BC30469] Reference to a non-shared member requires an object reference."

    I tried leaving off the "Code." or replacing "Code." with "Me.".  Neither worked.  Is there any way to call one method in custom code from another method?

    Thursday, October 2, 2008 7:42 PM

Answers

  • I had since modified the code to no longer use the function.  When I attempted to re-create the code that did not compile, it now compiles and performs correctly!  Obviously, I have coded something differently now than before, but I don't know what.  Anyway, if it works, I'm happy.  Thanks for your efforts - you must have spurred me into doing something different, even if subconciously.
    Friday, October 3, 2008 4:12 PM

All replies

  • Hi
        Remove "Code." and it should be ok. You need it for example when you want to run function from report field.

    everything is a matter of probability...
    Friday, October 3, 2008 1:35 PM
  •  I tried leaving off the "Code." or replacing "Code." with "Me."  Neither worked.
    Friday, October 3, 2008 1:37 PM
  • Can you paste whole custom code block?
    everything is a matter of probability...
    Friday, October 3, 2008 1:58 PM
  • I had since modified the code to no longer use the function.  When I attempted to re-create the code that did not compile, it now compiles and performs correctly!  Obviously, I have coded something differently now than before, but I don't know what.  Anyway, if it works, I'm happy.  Thanks for your efforts - you must have spurred me into doing something different, even if subconciously.
    Friday, October 3, 2008 4:12 PM