title: VB.NET Simplify Action(Of T)
body: <p>I am using VB.Net 4 and am successfully using a class with the following signature:</p>
  
  <blockquote>
    <p>Sub Register(Of TMessage)(recipient As Object, action As
    System.Action(Of TMessage))</p>
  </blockquote>
  
  <p>I want to learn about lambdas in VB so I wanted to see if I can simplify my current code.</p>
  
  <p>CURRENTLY: I have the following in the constructor of a class (simplified for clarity)</p>
  
  <pre><code>Public Sub New()
      Dim myAction As New Action(Of String)(AddressOf HandleMessage)
      Messenger.Default.Register(Of [String])(Me, myAction)            
  End Sub
  </code></pre>
  
  <p>And later in the class I have the following:</p>
  
  <pre><code>Private Function HandleMessage(sMsg As String)
      If sMsg = "String Value" Then
          If Me._Selection.HasChanges Or Me._Selection.HasErrors Then
              Return True
          End If
          Return False
      Else
          Return False
      End If
  End Function
  </code></pre>
  
  <p>QUESTION: Is there a way to simplify this into a lambda like in C# where I don't have to declare the MyAction variable in the constructor, but just pass the string value to HandleMessage function "<strong>inline</strong>" with the register sub? (I hope that makes sense)</p>