Code Comments
Programming Forum and web based access to our favorite programming groups.Good afternoon, folks. Have a newbie question that I hope someone might assist me with. Have a basic form and class module. Code for the form is thus: ----- Private Sub Form_Load() Dim clsClass1 As New Class1 On Error GoTo ErrorRoutine clsClass1.Test ' If I replace the above line with this: ' Err.Raise vbObjectError + 513, , "Some error happened here." ' the error handling works as expected. MsgBox "How come this text gets displayed??" Unload Me Exit Sub ErrorRoutine: MsgBox "Error: " & Err.Description, vbOKOnly, "Error #" & Err.Number Exit Sub End Sub ----- Code for the class module is thus: ----- Public Sub Test() On Error Resume Next Err.Raise vbObjectError + 513, , "Error in class module." End Sub ----- Can someone explain why, when the error is raised in the class module, the 'ErrorRoutine' handler isn't followed? That line 'MsgBox "How come this text gets displayed"' should never be displayed?? Thanks so much, Shawn. sferrier at gmail dot com
Post Follow-up to this messageHi Shawn: Because you have set On Error Resume Next, vb will ignore the error you raised. Try removing the On Error Resume Next from Test and see what happens. Doug. "Shawn Ferrier" <jeanchretien2@hotmail.com> wrote in message news:daf1bfeb.0409281330.1bff7 db6@posting.google.com... > Good afternoon, folks. > > Have a newbie question that I hope someone might assist me with. Have > a basic form and class module. Code for the form is thus: > > ----- > Private Sub Form_Load() > Dim clsClass1 As New Class1 > > On Error GoTo ErrorRoutine > clsClass1.Test > ' If I replace the above line with this: > ' Err.Raise vbObjectError + 513, , "Some error happened here." > ' the error handling works as expected. > MsgBox "How come this text gets displayed??" > Unload Me > Exit Sub > > ErrorRoutine: > MsgBox "Error: " & Err.Description, vbOKOnly, "Error #" & Err.Number > Exit Sub > End Sub > ----- > > Code for the class module is thus: > ----- > Public Sub Test() > On Error Resume Next > Err.Raise vbObjectError + 513, , "Error in class module." > End Sub > ----- > > Can someone explain why, when the error is raised in the class module, > the 'ErrorRoutine' handler isn't followed? That line 'MsgBox "How > come this text gets displayed"' should never be displayed?? > > Thanks so much, > Shawn. > sferrier at gmail dot com
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.