Link to home
Start Free TrialLog in
Avatar of uron6342
uron6342

asked on

VB error numbers

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
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of uron6342
uron6342

ASKER

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
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.
Avatar of Ark
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
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