title: How to pass a widestring variable from Delphi to VB as string
body: <p>Delphi code</p>
  
  <pre class="lang-pascal prettyprint-override"><code>procedure PassN1(out N1: widestring); stdcall;
  begin
    N1 := 'A';
  end;
  
  exports
    PassN1;
  end.
  </code></pre>
  
  <p>VB code</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Declare Sub PassN1 Lib "C:\path.dll" Alias "PassN1" (&lt;MarshalAs(UnmanagedType.BStr)&gt; ByRef N1 As String)
  
  ...
  
  Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
      Dim N1 = PassN1  'Expression does not produce a value.
      Try
          TabPage3.Text = N1
      Catch ex As Exception
      End Try
  End Sub
  </code></pre>
  
  <p>I get "Expression does not produce a value." How can I read the variable from VB?</p>