Err.LastDLLError (property)




Returns the last error generated by an external call, i.e. a call to a routine declared with the Declare statement that resides in an external module.


The Err.LastDLLError property is automatically set when calling a routine defined in an external module.

If no error occurs within the external call this property will automatically be set to 0.


'The following script calls the GetCurrentDirectoryA. If an

'error occurs, this Win32 function sets the Err.LastDLLError

'property which can be checked for.

Declare Sub GetCurrentDirectoryA Lib "kernel32" (ByVal DestLen _

As Integer,ByVal lpDest As String)

Sub Main()

  Dim dest As String * 256


  GetCurrentDirectoryA len(dest),dest

  If Err.LastDLLError <> 0 Then

    MsgBox "Error " & Err.LastDLLError & " occurred."


    MsgBox "Current directory is " & dest

  End If

End Sub

See Also

Error Handling (topic), Err.Clear (method), Err.HelpContext (property), Err.Description (property), Err.HelpFile (property), Err.Number (property), Err.Source (property)


This property is set by DLL routines that set the last error using the Win32 function SetLastError().

BasicScript uses the Win32 function GetLastError() to retrieve the value of this property. The value 0 is returned when calling DLL routines that do not set an error.

More information