Visual Basic Code Example: Reading Error Codes


Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The following error handler displays the value and description of an error returned by a Message Queuing call.


The Err object is the standard object used by other Visual Basic® applications. (This error handler is used in all Visual Basic examples provided by the Platform SDK.)

Code Example

On Error GoTo ErrorHandler  
' Make Message Queuing calls.  
  MsgBox "Error " + Hex(Err.Number) + " was returned." _  
          + Chr(13) + Err.Description