A read-only property containing a system error code representing a system error produced within a DLL called from a VB program.
Only direct calls to a Windows system DLL from VB code will assign a value to LastDLLError.
The value of the LastDLLError property depends upon the particular DLL being called. Your code must be able to handle the various codes that can be returned by the DLL you are calling.
Don’t forget that a failed DLL call does not itself raise an error within your VB program. As a result, the Err object’s Number, Description, and Source properties are not filled.
The LastDLLError property can be changed by VB at any time, so it is important to save the value in an independent variable as soon as possible.
The LastDLLError property is only used by system DLLs, such as kernel32.dll. Therefore, errors that occur within DLLs you may have created will not cause an error code to be assigned to the property.
Obtaining accurate documentation about the return values of system DLLs can be a challenging experience! Most useful information can be found by studying the API documentation for Visual C++. However, you can use the Win32 API FormatMessage function to return the actual Windows error message string from within Kernel32.DLL, which incidentally will also be in the correct language. The following is a brief example that you can ...