|
-
Jun 8th, 2001, 03:12 AM
#1
Thread Starter
Addicted Member
Pleeaassee
could someone give me the routine for getting the last error.
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
-
Jun 8th, 2001, 03:46 AM
#2
Frenzied Member
Within the context of an API call, the last error is held in VB's intrinsic Err.LastDllError member.
To transalate that into a sensible error message:
Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
Public Function LastSystemError() As String
Const FORMAT_MESSAGE_FORM_SYSTEM = &H1000
Dim sError As String * 500
Dim lErrMsg As Long
lErrMsg = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, Err.LastDllError, sError, Len(sError), 0)
LastSystemError = Trim$(sError)
End Function
HTH,
D.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|