Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


HELP!


HELP!

Author
Message
Michael_qq
Michael_qq
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 11, Visits: 20
Hi, I got a code which has a lot of bugs from others. I try to debug it.
I need somebody teach me on how to use Err.Raise method.

The original code has the following structure:

private sub main()
       ::::::
       funct1()
       ::::::
end sub

public sub funct1()
       ::::
    on error goto err_hdl01
       ::::
       sub_routine3()
       ::::
       exit sub

err_hdl01:
     err_raise()
     exit sub
end sub


private sub err_raise()
       err.number = 12345
       err.description = "abcdefg"
       err.source = "xyz"
       err.raise err.number, err.source, err.description
end sub

My question is:
if Sub_routine3 returns an error, funct1 will goto err_hdl01, then it will call err_raise() which will raise another error. where does the code return to?

if Sub_routine3 returns an error, will this code fall in a died loop?

Thank you for your advice in advance.


Michael_qq
jviper
jviper
Forum God
Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)

Group: Forum Members
Posts: 10, Visits: 28
I think that as soon as there is an error, it will fall to the err_hdl01. So when you raised the error in the funct3, it will exit that function, and go striaght to the err_hdl01. When you raise an error outside of the On Error checking, the error will show up and crash the program.

Jabstract: Don't just imagine, make it happen!
Michael_qq
Michael_qq
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 11, Visits: 20
Thank you, Jviper.

You mentioned "outside of the On Error checking".

Can you please explain how the "On Error checking" area definied?
Thanks again.


Michael_qq
jviper
jviper
Forum God
Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)Forum God (3.3K reputation)

Group: Forum Members
Posts: 10, Visits: 28
The error trapping works like this...

Private Sub SubRoutine

On Error Goto Label

  Do Do

  Do

  Do

  Doh!

On Error Goto 0

Exit Sub ' Ok, we've done our job here, let's get out

Label:

  Doh: There was an Error!!!

  Your in trouble, you have the right to remain silent, anything you say can and will be used agaist you the court of law........ blah, blah, blah, now do somthing about it!

   'Show a message box, or somthing, anything but what caused the error.........

   MsgBox "Error!!!!!!","Hey, dummy.......you can't to that"

End Sub

Now what will happen is, if an error occurs between On Error Goto Label, and On Error Goto 0, the the program will immedietely jump to label. Once it makes it past The On Error Goto 0, now if an error occurs, execution of the program will stop, and you will be promped with the error.

Jabstract: Don't just imagine, make it happen!

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search