home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Software Sampler
/
Visual_Basic_Software_Sampler_Visual_Basic_Programmers_Journal_June_1996.iso
/
issues
/
04apr96
/
code
/
p117.txt
< prev
next >
Wrap
Text File
|
1996-04-24
|
2KB
|
62 lines
[[listing 1]]
[[VB4]]
Declare Function FormatMessage Lib "kernel32" _
Alias "FormatMessageA" _
(ByVal dwFlags As Long, _
lpSource As Long, _
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_FROM_SYSTEM = &H1000
Public Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200
Private Sub cmdFormat_Click()
Dim sBuff As String
Dim lMsgId As Long
sBuff = String(256, " ")
lMsgId = CLng(Val(txtID))
ret& = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM Or _
FORMAT_MESSAGE_IGNORE_INSERTS, _
0&, lMsgId, 0&, sBuff, Len(sBuff), 0&)
lblMessage = sBuff
End Sub
[[listing 2]]
[[VB4]]
Private Const errFetchOne = vbObjectError + 2001
Private Const errFetchTwo = vbObjectError + 2002
Private Const errFetchDefault = vbObjectError + 2000
Private Const errFetchExternal = vbObjectError + 2999
Public Sub Fetch()
On Error GoTo ErrHandler
'...Code goes here
Exit Sub
ErrHandler:
If Err.Source <> DefaultErrSource Then
'External error
Err.Raise _
Number:=errFetchExternal, _
Source:=DefaultErrSource _
& "[" &Err.Source & "]"
Else
Select Case Err.Number
Case errFetchOne
Err.Raise _
Number:=errFetchOne, _
Description:=LoadResString(errFetchOne)
'Case errFetchTwo...
Case Else
Err.Raise _
Number:=errFetchDefault, _
Description:=LoadResString(errFetchDefault)
End Select
End If
End Sub
1 02/06/96 10:03 AM