Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Another Lambda Expression Problem

Another Lambda Expression Problem

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabaselinq
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sonhospa
    wrote on last edited by
    #1

    Hello again, it seems that code translation tools have their problems with Lambda expressions – different from my own :( but still ... Maybe you can help me again: C#-code

    EventHandler local = this.MailPopped;
    if (local != null){local(this, new MailPoppedEventArgs(index, message, size, uidl, receivedTime));}

    has been translated to VB.NET this way:

    Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
    If local IsNot Nothing Then local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))

    The resulting error message reminds me that 'MailPopped' is an event so that a 'RaiseEvent' construction is needed. But which would be a proper syntax for the above expression? :confused: Thank you in advance Mick

    W D 2 Replies Last reply
    0
    • S Sonhospa

      Hello again, it seems that code translation tools have their problems with Lambda expressions – different from my own :( but still ... Maybe you can help me again: C#-code

      EventHandler local = this.MailPopped;
      if (local != null){local(this, new MailPoppedEventArgs(index, message, size, uidl, receivedTime));}

      has been translated to VB.NET this way:

      Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
      If local IsNot Nothing Then local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))

      The resulting error message reminds me that 'MailPopped' is an event so that a 'RaiseEvent' construction is needed. But which would be a proper syntax for the above expression? :confused: Thank you in advance Mick

      W Offline
      W Offline
      Wayne Gaylard
      wrote on last edited by
      #2

      It would look something like this

      Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
      RaiseEvent local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))

      Hope this helps

      When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

      S 1 Reply Last reply
      0
      • W Wayne Gaylard

        It would look something like this

        Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
        RaiseEvent local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))

        Hope this helps

        When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

        S Offline
        S Offline
        Sonhospa
        wrote on last edited by
        #3

        Hi Wayne, I'm going to check it out asap. Thanks for your help! :thumbsup:

        1 Reply Last reply
        0
        • S Sonhospa

          Hello again, it seems that code translation tools have their problems with Lambda expressions – different from my own :( but still ... Maybe you can help me again: C#-code

          EventHandler local = this.MailPopped;
          if (local != null){local(this, new MailPoppedEventArgs(index, message, size, uidl, receivedTime));}

          has been translated to VB.NET this way:

          Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
          If local IsNot Nothing Then local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))

          The resulting error message reminds me that 'MailPopped' is an event so that a 'RaiseEvent' construction is needed. But which would be a proper syntax for the above expression? :confused: Thank you in advance Mick

          D Offline
          D Offline
          Dave Doknjas
          wrote on last edited by
          #4

          You'll need to use the hidden VB event field (add "Event" to the event name):

          Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPoppedEvent

          David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups