We help IT Professionals succeed at work.

VB error numbers

uron6342
uron6342 asked
on
Medium Priority
563 Views
Last Modified: 2007-12-19
Hi-

Are all errors that can be generated by VB over the value of one?

I haven't been able to locate a list of these errors.

Thanks - u
Comment
Watch Question

Head of Software Services
CERTIFIED EXPERT
Commented:
By VB as such yes, however various components that you use in VB such as ADO may well generate error numbers less than one. Equally an error that is caused by VB but is actually reported by the operating system may also be less than one. There is a reasonably complete list of errors on MSDN, do a search on LONG TRAPPABLE either on your own copy or on the net at msdn.microsoft.com

Author

Commented:
this is from msdn...

You create custom errors by using the VB built-in vbObjectError constant, then adding an offset. Microsoft reserves error values between vbObjectError and vbObjectError + 512, so you must start custom errors at offset 513 or greater. The vbObjectError constant is equivalent to hex value 80040000, which prints out as value -2147221504 if you display its decimal equivalent. Therefore, it's often convenient to display custom errors as hex values (using the Hex$ function), as shown in the ClassErr routine.

im think i may be more confused. i belive a type mismatch is '13'. how is this so if the base is way into the negatives?

basically, i just one error number that i can use that will not be used by ado, cdo ... or any of the other libraries i am using.

thanks - u

Commented:
Add a command button to a form and try this:

Private Sub Command1_Click()
  On Error GoTo x
  Dim errnum As Integer
  Debug.Print vbCrLf; vbCrLf; vbCrLf
 
  errnum = -10
  Do
    Err.Raise errnum
    errnum = errnum + 1
  Loop Until errnum > 100
  Exit Sub
x:
  Debug.Print Err.Number & " - " & Err.Description
  Resume Next
End Sub

--
Obviously, you could write these messages to a listbox or file if you want since the debug window seems to only hold about 150 lines on my system.
Ark
CERTIFIED EXPERT

Commented:
Hi
'Add ListBox and Command Button on your form:

Private Sub Command1_Click()
   Me.Caption = "VB Errors"
   Dim strErr As String
   List1.Clear
   Me.MousePointer = vbHourglass
   For i = 1 To 1000
      strErr = VBErrorText(i)
'To avoid "Application defined error" message
      If Left$(strErr, 11) <> "Application" Then List1.AddItem CStr(i) & ": " & strErr
   Next i
   Me.MousePointer = 0
End Sub

Private Function VBErrorText(ByVal ErrNum As Long) As String
   VBErrorText = Error(ErrNum)
End Function
Ark
CERTIFIED EXPERT

Commented:
Oops, seems I understood you. You're speaking about thouse big negative numbers like -2147467249? It's an OLE errors. They are stored in kernel32.dll. Take a look on my samples:
http://www.freevbcode.com/ShowCode.Asp?ID=2990

you'get ALL system errors.

Cheers

Explore More ContentExplore courses, solutions, and other research materials related to this topic.