none
Visual basic 6 conversion to VB2013 "Add a delegate for AddressOf"

    Question

  • I have converted a rather large program from Visual Basic 6 to VB2013 by first using the conversion package in VB2008.  Below is the code and warning I am getting.

    ModuleucString

         FunctionucEqual() AsDouble

               ucEqual = System.Math.Abs(CInt(ucParamStr(1) = ucParamStr(2)))

         EndFunction

              SubucInitStringRelational()

     

              'UPGRADE_WARNING: Add a delegate for AddressOf ucEqual

               ucDefineFunction("Equal[a$,b$]", AddressOfucEqual)

              EndSub

    EndModule

    I The error I am getting is "100 addressof expression can not be converted to integer because integer is not a delegate type"

    Any insight would be greatly appreciated

    Thursday, January 12, 2017 11:28 AM

All replies

  • Where is ucDefineFunction defined? Anyway, you need to define a delegate for the ucEqual function, and make usDefineFunction to receive its second parameter of the type of that delegate. For example:

    Module ucString
    
       Function ucEqual(ucParamStr() As String) As Double
    
          ucEqual = System.Math.Abs(CInt(ucParamStr(1) = ucParamStr(2)))
    
       End Function
    
       Delegate Function ucEqualDelegate(ucParamStr() As String) As Double
    
       Sub ucInitStringRelational()
    
          ucDefineFunction("Equal[a$,b$]", AddressOf ucEqual)
    
       End Sub
    
       Sub ucDefineFunction(s As String, d As ucEqualDelegate)
    
       End Sub
    
    End Module
    



    My portal and blog about VSX: http://www.visualstudioextensibility.com Twitter: https://twitter.com/VSExtensibility MZ-Tools productivity extension for Visual Studio: https://www.mztools.com

    Thursday, January 12, 2017 1:13 PM
  • Thanks Carlos J. Quintero.

    Hi SJ Bailey,

    Welcome to the MSDN forum.

    Does your issue is solved or not? If not, please feel free to let me know.

    If you think Carlos's reply is helpful for your issue, please mark it as answer, that will help other community members who have the same or similar issue to easier search this useful solution, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 16, 2017 8:40 AM
    Moderator