Resuming from an error

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
 
M

Mr. Arnold

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.
 
A

Armin Zingler

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
 
D

diwen

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
 
H

Herfried K. Wagner [MVP]

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'.
 
P

Phill W.

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

Top