title: Create DLL file in VB.NET and use in Excel VBA
body: <p>I have created a DLL file in VB.NET and I want use it in Excel VBA. When I use it like a function it is working perfect but when I use sub with a <code>ByRef</code> variable it does not work and Excel restarts with an error.</p>
  
  <p>The code in VB.NET is:</p>
  
  <pre><code>Public Function distinctArr(ByVal arr As String()) As String()
          Return arr.ToList.Distinct.ToArray
  End Function
  
  Public Sub sortArr(ByVal arr As String(), ByRef a As String())
      Dim tolist As List(Of String) = arr.ToList
      tolist.Sort()
      a = tolist.ToArray
  End Sub
  </code></pre>
  
  <p>This is the code in VBA:    </p>
  
  <pre><code>Dim objMda As Excelcode.mda
  Set objMda = New Excelcode.mda
  Dim distinc_Item() As String
  Dim all_Items() As String
  all_Items = rng_to_string(rng_rizmetre)
  distinc_Item = objMda.distinctArr(all_Items) '''This line is working perfect
  Dim Sorted_Item() As String
  objMda.sortArr distinc_Item, Sorted_Item
  </code></pre>
  
  <p>What is wrong with the code?</p>