Results 1 to 2 of 2

Thread: Pleeaassee

  1. #1

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179

    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

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616

    Lightbulb

    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
  •  



Click Here to Expand Forum to Full Width