title: How to correctly use On Error Goto for different HRESULT values
body: <p>I am trying to read a file. The call is from VB to CPP dll.</p>
  
  <p>Here is my sample code snippet</p>
  
  <p>VB CALL </p>
  
  <pre><code>  Private Sub ReadFile(...)
      On Error GoTo Problem
      Dim errorString As String
      Sample.ReadFile basepath, filename, register, errorString
      GoTo Completed
  Problem:
      WriteToLogFile basepath + filename + errorString //error string contains the formatted hresult message from cpp dll
  </code></pre>
  
  <p>My CPP function:</p>
  
  <pre><code>HRESULT ReadFile(...)
  {
  
  hr= actualread(...)
  if(FAILED(hr)
  {
  return E_FAIL // 
  }
  </code></pre>
  
  <p>If I change <code>E_FAIL</code> to <code>ERROR_FILE_NOT_FOUND</code> VB is not logging the error message. </p>
  
  <p>The <code>E_FAIL</code> message description is <strong>Unspecified error.</strong> Which does not help the user much.</p>
  
  <p>It logs E_POINTER,E_HANDLE etc anything that starts with E_ not with ERROR_ </p>