Returns or sets a String expression specifying the name of the object or application that originally generated the error. Read/write.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
The Source property specifies a String expression representing the object that generated the error; the expression is usually the object's class name or process ID. Use the Source property to provide information when your code is unable to handle an error generated in an accessed object. For example, if you access Microsoft Excel and it generates a Division by zero error, Microsoft Excel sets Err.Number to its error code for that error and sets Source to "Excel.Application".
When the application is generating an error from code, Source is your application's programmatic ID. Within a class, Source should contain a name having the form project.class. When an unexpected error occurs in your code, the Source property is automatically filled in. For errors in a module, Source contains the project name.
This example demonstrates the use of the Source property in a typical error-handling routine. When an error is raised from Class1, the string "Class1" is assigned to the Source property of the Err object. This string is then displayed in an informative message indicating the source and number of the error.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.