title: Using Delegates in vb.net
body: <p>I'm new to vb.net and trying to build a win CE app in vb.net. The sdk of the handheld device is in C# which I converted with an online converter to vb.net.
  Below is the C# code:</p>
  
  <pre><code>public class DecodeEventArgs : EventArgs
  {
      private string barcode;
      private byte type;
  
      public DecodeEventArgs(string barcodeData, byte typeData)
      {
          barcode = barcodeData;
          type = typeData;
      }
  
      public string Barcode
      {
          get { return barcode; }
          set { barcode = value; }
      }
  
      public byte Type
      {
          get { return type; }
          set { type = value; }
      }
  
  }
  </code></pre>
  
  <p>Converted to vb.net as:</p>
  
  <pre><code>Public Class DecodeEventArgs
      Inherits EventArgs
      Public barcode As String
      Public type As Byte
  
      Public Sub New(ByVal barcodeData As String, ByVal typeData As Byte)
          barcode = barcodeData
          type = typeData
      End Sub
  
      Public Property pBarcode() As String
          Get
              Return barcode
          End Get
          Set(ByVal value As String)
              barcode = value
          End Set
      End Property
  
      Public Property pType() As Byte
          Get
              Return type
          End Get
          Set(ByVal value As Byte)
              type = value
          End Set
      End Property
  End Class
  </code></pre>
  
  <p>In my conversion from C# I added a 'p' to the name of the Properties as you see in my vb.net code because I had a error that said </p>
  
  <blockquote>
    <p>Barcode is already declared as a public string in this class</p>
  </blockquote>
  
  <p>I'm not sure if that is part of my problem but my real issue is, on a form they used .BeginInvoke to call the class with this code:</p>
  
  <pre><code>void scanner_DecodeEvent(object sender, DecodeEventArgs e)
      {
          Win32.sndPlaySound(Properties.Resources.Scan, Win32.SND_ASYNC | Win32.SND_MEMORY);
  
          this.BeginInvoke((Action&lt;string&gt;)delegate(string barcode)
          {
              scanCount = 0;
              ListViewItem item = new ListViewItem(new string[] { barcode });
              lstView.Items.Insert(0, item);
  
          }, e.Barcode);
      } 
  </code></pre>
  
  <p>Which I converted to vb.net as:</p>
  
  <pre><code>Private Sub scanner_DecodeEvent(ByVal sender As Object, ByVal e As DecodeEventArgs)
      PlaySound()
  
      Me.BeginInvoke(DirectCast(Barcode As String) ) 
      scanCount = 0
      Dim item As New ListViewItem(New String() {barcode})
  
      lstView.Items.Insert(0, item)
  
  
  End Sub 
  </code></pre>
  
  <p>Which gives me an error about Barcode not being declared. This is where I'm stuck. Thanks for your assistance in advance</p>