Results 1 to 7 of 7

Thread: [RESOLVED] Lamda function at PUBLIC Declaration

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Resolved [RESOLVED] Lamda function at PUBLIC Declaration

    how to declare Lamda function at PUBLIC with in a class




    error code
    PHP Code:
    Public Class ExClass

     Dim _duplicatedocumentJSC 
    As Func(Of Boolean)
     Public Function 
    Getvalue () as boolean
       _duplicatedocumentJSC 
    = Function(_newName$) As Boolean
                                          
    ' Getting Error here  :
                                          Nested function does not have a signature that is compatible with delegate '
    <delegatename>'

                                  End Function
     End Function

    End Class 

    Below code is working fine
    PHP Code:
    Public Class ExClass

     Dim _duplicatedocumentJSC 
    As Func(Of Boolean)
    Public Function 
    Getvalue () as boolean
       _duplicatedocumentJSC 
    = Function() As Boolean
            
                                   End 
    Function
     
    End Function
    End Class 

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Lamda function at PUBLIC Declaration

    You declared the function signature as parameterless, then tried to create the function with a parameter... so yeah, of course the signatures don't match.

    Code:
     Dim _duplicatedocumentJSC As Func(Of Boolean)(somename as string)
     Public Function Getvalue () as boolean
       _duplicatedocumentJSC = Function(_newName$) As Boolean
                                          ' Getting Error here  :
                                          Nested function does not have a signature that is compatible with delegate '<delegatename>'
    
                                  End Function
     End Function
    
    End Class

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Lamda function at PUBLIC Declaration

    Quote Originally Posted by techgnome View Post
    You declared the function signature as parameterless, then tried to create the function with a parameter... so yeah, of course the signatures don't match.

    Code:
     Dim _duplicatedocumentJSC As Func(Of Boolean)(somename as string)
    That will not work, the signature is that it takes a string and returns a boolean so it should look like this:
    Code:
    Private _duplicatedocumentJSC As Func(Of String, Boolean)

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Lamda function at PUBLIC Declaration

    Ugh... yeah. sorry... I had Generics on the brain when I wrote that and no chance to try it out.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Re: Lamda function at PUBLIC Declaration

    yes

    PHP Code:
    Private _duplicatedocumentJSC As Func(Of StringBoolean
    it's working fine sir
    thank you techgnome n Joacim Andersson.....


    but i troubled the another one ...
    PHP Code:
    Public Class ExClass

     Dim _duplicatedocumentJSC  
    As Func(Of StringBoolean)
    Public Function 
    Getvalue () as boolean
       _duplicatedocumentJSC 
    = Function(Byval _newname$ , ByRef getlayerSize  as SizeF) As Boolean
                                          
    ' Getting Error here  :
                                          Nested function does not have a signature that is compatible with delegate '
    <delegatename>'

                                         End Function
     End Function
    End Class 
    m using ByRef

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Lamda function at PUBLIC Declaration

    You can't use the generic delegate Func(Of ...) if one of the arguments is to be passed ByRef you need to declare your own delegate for that.
    Code:
    Delegate Function MyFunc(s As String, ByRef sf As SizeF) As Boolean
    Private _duplicatedocumentJSC As MyFunc

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Re: [RESOLVED] Lamda function at PUBLIC Declaration

    thanQ sir

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width