Error trapping in vb6

stoymigo

Senior Member
Joined
Dec 11, 2008
Messages
975
Reaction score
26
When I run the following code, it gives me a "Division by zero" error, the thing I'm wondering is why doesn't it go to the error handler, even though I have one.

Code:
Private Sub Form_Load()
1         On Error GoTo Form_Load_Error
          Dim iValue As Integer
2         iValue = 5 / 0 'bombs out
3         MousePointer = vbHourglass
4         MousePointer = vbDefault
5         On Error GoTo 0
6         Exit Sub

Form_Load_Error:
7         MsgBox "Line: " + CStr(Erl) + " Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of Form Form1"

End Sub
 
Omg, I'm getting horrendous flasbacks...

How 'bout: "on error resume next" lol...

Honestly, its been millinia since my vb days, and I can't remember how to solve that issue. Sorry!

Good luck though!


Sent from my GT-I9100 using Tapatalk
 
Perhaps your error handler has an error? Does erl exist?
 
Your code works fine, it calls the error handling on my pc
 
If I remember correctly you have to set the IDE to only break on unhandled errors. Check in the options somewhere.
 
check tools-> options-> general, if error trapping is set to "break on all errors", change to break in class module or on unhandled errors
 
Yep, changing from "break on all" to something else fixes this.
 
he doesn't need the second 'on error', probably put it in there while he was debugging his issue
 
Top
Sign up to the MyBroadband newsletter
X