I've created a module that contains all error numbers and the text of the error. It is intended to be placed in the top of the main program, so the info is available for any part of the program. It has been written to work even in OPTION _EXPLICIT programs.
(03-25-2024, 06:49 PM)TDarcos Wrote: [ -> ]I've created a module that contains all error numbers and the text of the error. It is intended to be placed in the top of the main program, so the info is available for any part of the program. It has been written to work even in OPTION _EXPLICIT programs.
This is super helpful. Thanks! However, you do not need ERR_TEXT$. You can just call
_ERRORMESSAGE$ using the error code constant.
Thanks, that's EXTREMELY helpful... FOR STEVE! Me, I'll never use it.
Pette
This program displays all Windows error messages:
Code:
Rem search for error messages in windows
Declare Dynamic Library "kernel32"
Function FormatMessageA& (ByVal f As Long, f$, Byval e As Long, Byval d As Long, g$, Byval s As Long, h$)
Function GetLastError& ()
End Declare
' count error messages
Dim m As String * 260
For x& = 1 To 15299
y& = FormatMessageA&(&H1200, "", x&, 0, m$, 260, "")
If y& Then
c = c + 1
x$ = "Error 0x" + Hex$(x&) + " (" + LTrim$(Str$(x&)) + ")"
y$ = Left$(m$, y& - 2)
length = length + Len(x$) \ 80 + Len(y$) \ 80 + 2
If length >= 22 Then
length = 0
If p = 0 Then
Color 15
Print "-more(y/n/c)-";
Do
_Limit 50
z$ = LCase$(InKey$)
If z$ = "c" Then p = -1: Print: Exit Do
If z$ = "y" Then Print: Exit Do
If z$ = "n" Then Print: Exit For
Loop
End If
End If
Color 14
Print x$
Print y$
End If
Next
Color 14
Print "There were"; c; "messages found."
Color 7
End
Of course you could do this:
Code:
For x% = 1 To 1024
e$ = _ErrorMessage$(x%)
e$ = RTrim$(e$)
If LCase$(e$) = "unprintable error" Then
' nul
Else
Print x%; e$
End If
Next
End