VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Errors, Returning API human readable descriptions. Returns system description for all error numbers

by T-REX Software (14 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 24th March 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Errors, Returning API human readable descriptions. Returns system description for all error numbers

API Declarations


(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 Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
Public Const FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000
Public Const FORMAT_MESSAGE_FROM_HMODULE = &H800
Public Const FORMAT_MESSAGE_FROM_STRING = &H400
Public Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Public Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200
Public Const FORMAT_MESSAGE_MAX_WIDTH_MASK = &HFF
Public Const LANG_USER_DEFAULT = &H400&

Function GetLastErrorStr(dwErrCode As Long) As String
Static sMsgBuf As String * 257, dwLen As Long
dwLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM _
Or FORMAT_MESSAGE_IGNORE_INSERTS Or FORMAT_MESSAGE_MAX_WIDTH_MASK, ByVal 0&, _
dwErrCode, LANG_USER_DEFAULT, ByVal sMsgBuf, 256&, 0&)
If dwLen Then GetLastErrorStr = Left$(sMsgBuf, dwLen)
End Function

Rate Errors, Returning API human readable descriptions. Returns system description for all error numbers



'Sub needs a textbox and label

Dim x
x = GetLastErrorStr(Val(Text1.Text))
Label1.Caption = x


Download this snippet    Add to My Saved Code

Errors, Returning API human readable descriptions. Returns system description for all error numbers Comments

No comments have been posted about Errors, Returning API human readable descriptions. Returns system description for all error numbers. Why not be the first to post a comment about Errors, Returning API human readable descriptions. Returns system description for all error numbers.

Post your comment

Subject:
Message:
0/1000 characters