Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Error handling with a class module (VB6)
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

Report this thread to moderator Post Follow-up to this message
Old Post
Shawn Ferrier
09-29-04 01:55 AM


Re: Error handling with a class module (VB6)
Hi 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



Report this thread to moderator Post Follow-up to this message
Old Post
Douglas Marquardt
09-29-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:39 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.