Try Catch -- how to resume??

R

Rob R. Ainscough

Coming from VB6 to VB.NET, it appears if I opt to use the Try Catch approach
I don't have any way to RESUME from within my catch statement?

What I often do is resolve the problem in my catch statement and then I want
to resume at either the same statement that triggered the error or the
following statement. Perhaps I should not be using Try...Catch approach?

Any suggestions?

Thanks, Rob
 
R

Rob R. Ainscough

I thought GOTO was removed from VB.NET?? Thanks for the suggestion, but
GOTO is something I want to avoid as much as possible.

Rob
 
T

Tom Spink

Hi Kovan.....

NOOOooooo..... not goto :(

*ahem*

Hi Rob,

To reolve this, you'll have to place a Try..Catch block around the offensive
line...

Try

Foo()
Bar()

Try
Baz()
Catch ex As Exception
' Blah
End Try

Moo()
Goo()

Catch ex As Exception
' Blah
End Try

Using the old-style error-trapping... i.e. On Error Resume Next is bad
because it's unstructured. Try...Catch...Finally is structured exception
handling and performs better in the managed world.

Structured and Unstructured exception handling can *not* be mixed.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
R

Robains

Tom,

Thanks, I see what you're saying -- will take some restructuring to my
approach. It is hard to undo VB6 habits as they continue to
influence my .NET code.

Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top