Resuming from an error

  • Thread starter Thread starter Jerry West
  • Start date Start date
J

Jerry West

In VB6 one could use 'Resume Next' to have program execution resume at the
statement following where an error occurred. Is there something comparable
in VB .NET?

Try

i = 0 / 0

DoEvenMore

Catch ex As Exception



End Try

If the eval of i creates an error how do I have the Catch block resume
execution at the procedure DoEvenMore?

JW
 
Jerry West said:
In VB6 one could use 'Resume Next' to have program execution resume at the
statement following where an error occurred. Is there something comparable
in VB .NET?

Try

i = 0 / 0

DoEvenMore

Catch ex As Exception



End Try

If the eval of i creates an error how do I have the Catch block resume
execution at the procedure DoEvenMore?

You know, you can do an On Error GoTo and Resume Next, which you'll have to
get rid if the try/catch.
 
Jerry West said:
In VB6 one could use 'Resume Next' to have program execution resume
at the statement following where an error occurred. Is there
something comparable in VB .NET?

Try

i = 0 / 0

DoEvenMore

Catch ex As Exception



End Try

If the eval of i creates an error how do I have the Catch block
resume execution at the procedure DoEvenMore?

Try

i = 0 / 0

Catch
'no code here. ignore exception.
End Try

DoEvenMore


Don't be surprised if you don't get an exception in this case at all...


Armin
 
Jerry said:
In VB6 one could use 'Resume Next' to have program execution resume at the
statement following where an error occurred. Is there something comparable
in VB .NET?
Try
i = 0 / 0
DoEvenMore
Catch ex As Exception
End Try
If the eval of i creates an error how do I have the Catch block resume
execution at the procedure DoEvenMore?
JW

How about

Try
i = 0 / 0
Catch ex As DivideByZeroException
' i = 0 ?
Finally
DoEvenMore()
End Try
 
Armin Zingler said:
Try

i = 0 / 0

Catch
'no code here. ignore exception.
End Try

DoEvenMore

ACK, but you'd have to put each statement in a separate 'Try...Catch' block
in order to receive a behavior similar to those of 'Resume Next'.
 
Jerry said:
In VB6 one could use 'Resume Next' to have program execution resume at the
statement following where an error occurred. Is there something comparable
in VB .NET?

Yes.

"On Error Resume Next"

Yes, it /still/ works; if you really, /really/ want to.

More likely, though, you'll want to use Try .. Catch ... won't you!?

Sub X()
Try
DoSomethingDodgy()
Catch ex As Exception
' Do Nothing
End Try

DoEvenMore()

End Sub

Unless you [re-]throw the Exception out of the Catch, execution
continues with the next statement /after/ the End Try.

HTH,
Phill W.
 

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

Resuming Try 4
resume next in VB.NET ? 10
On Error Resume Next 25
Try catch and Resume 15
How to implement "On Error Resume"? 6
On error resume next bug 4
Replacement for Resume Next 7
Excel On Error Resume Next 2

Back
Top