VB: Error with AddressOf

4 posts, 0 answers
  1. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 16 Dec 2009 Link to this post

    Hi,

    I use code like that in VB:

    Sub x() 
       DoWsCall = AddressOf DoWsCallCommit 
    End Sub 
     
    Private Function DoWsCallCommit() As ShoppingCartResult 
    End Function 

    JustCode throws an error for "AddressOf DoWsCallCommit":

    VisualBasic.Net: There is no applicable member or variable 'DoWsCallCommit'



    Thanks
    Eric
  2. Jordan
    Admin
    Jordan avatar
    123 posts

    Posted 17 Dec 2009 Link to this post

    Hi EricSch,

    Thanks for the involvement. I try to reproduce the problem you reported with following code:

     

    01.Public Class Class2
    02.    Delegate Function DelegateType() As Integer
    03. 
    04.    Sub x()
    05.        Dim DoWsCall = New DelegateType(AddressOf DoWsCallCommit)
    06.    End Sub
    07. 
    08.    Private Function DoWsCallCommit() As Integer
    09. 
    10.    End Function
    11.End Class

    There isn't any Visual Studio or JustCode errors in it. After I remove the New DelegateType from line 5. 

    JustCode found an error VisualBasic.Net: There is no applicable member or variable 'DoWsCallCommit'. Visual Studio found 'AddressOf' expression cannot be converted to 'Object' because 'Object' is not a delegate type.

    Is the same happen to you?

    What is the declaration of DoWsCall in your case?


    All the best,
    Jordan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 17 Dec 2009 Link to this post

    Hi,

    My exact definition for the delegate is:

            Delegate Function WsCallDelegate() As ShoppingCartResult  
        
            Dim DoWsCall As WsCallDelegate 

    There's no error is Visual Studio, only in JustCode.

    Thanks
    Eric
  5. Jordan
    Admin
    Jordan avatar
    123 posts

    Posted 19 Dec 2009 Link to this post

    Hello EricSch,

     

    We couldn't reproduce your problem. Could you send us a small sample project that demonstrates it? You can open a ticket and attach the sample project there.

     

    All the best,
    Jordan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top