Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resuming from an error

19 views
Skip to first unread message

Jerry West

unread,
Sep 13, 2007, 5:25:36 PM9/13/07
to
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


diwen

unread,
Sep 13, 2007, 5:50:02 PM9/13/07
to

How about

Try
i = 0 / 0

Catch ex As DivideByZeroException
' i = 0 ?
Finally
DoEvenMore()
End Try

--
diwen

Armin Zingler

unread,
Sep 13, 2007, 5:49:41 PM9/13/07
to
"Jerry West" <j...@comcast.net> schrieb

Try

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

Arnold@arnold.com Mr. Arnold

unread,
Sep 13, 2007, 5:46:54 PM9/13/07
to

"Jerry West" <j...@comcast.net> wrote in message
news:13ejamm...@news.supernews.com...

You know, you can do an On Error GoTo and Resume Next, which you'll have to
get rid if the try/catch.

Herfried K. Wagner [MVP]

unread,
Sep 16, 2007, 7:05:25 AM9/16/07
to
"Armin Zingler" <az.n...@freenet.de> schrieb:

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

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Phill W.

unread,
Sep 17, 2007, 7:56:47 AM9/17/07
to
Jerry West wrote:

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

0 new messages