473,480 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Resuming Try

Hi

I have several statements in my try block. After catching an exception and
dealing with it in catch section, is there a way to resume from next
statement in try section kinda like resume next in vb?

Thanks

Regards
Jun 27 '08 #1
4 836
"John" <in**@nospam.infovis.co.ukschrieb
Hi

I have several statements in my try block. After catching an
exception and dealing with it in catch section, is there a way to
resume from next statement in try section kinda like resume next in
vb?
No. You'd have to put each single statement in a try-catch block - or
still use on error resume next.
Armin

Jun 27 '08 #2
On Apr 28, 10:38 pm, "John" <i...@nospam.infovis.co.ukwrote:
Hi

I have several statements in my try block. After catching an exception and
dealing with it in catch section, is there a way to resume from next
statement in try section kinda like resume next in vb?

Thanks

Regards
John,
You can use seperate try-catch exception handlers for each statements
alternatively.

Onur
Jun 27 '08 #3
John,
Yes, use a Goto statement.

Try
TryAgain1:
Something()
TryAgain2:
SomethingElse()
Catch
If whatever Then
Goto TryAgain1
Else
Goto TryAgain2
End If
End Try

Of course some people feel Goto is evil & should be avoided at all costs; I
view the above more of a "Resume Try" rather then a Goto statement. There
are three simple rules for Goto in a Catch block.

- A Goto can only branch from a Catch statement into the Try block of the
same statement
- A Goto can never branch out of a Finally statement
- A Goto can never branch into a Catch or Finally statement

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"John" <in**@nospam.infovis.co.ukwrote in message
news:OK**************@TK2MSFTNGP04.phx.gbl...
Hi

I have several statements in my try block. After catching an exception and
dealing with it in catch section, is there a way to resume from next
statement in try section kinda like resume next in vb?

Thanks

Regards
Jun 27 '08 #4

"John" <in**@nospam.infovis.co.ukwrote in message
news:OK**************@TK2MSFTNGP04.phx.gbl...
Hi

I have several statements in my try block. After catching an exception and
dealing with it in catch section, is there a way to resume from next
statement in try section kinda like resume next in vb?
If you want Resume Next then either use the solution Jay showed of using
GoTo from inside the Catch, or you can in fact use On Error Resume Next as
per Visual Basic 6 style of coding and the compiler does that GoTo and
labels for you, but you cannot mix and match that. Personally, I'd do
neither, instead I'd look at refactorign the code out that can cause errors
that you wish to still resume next from, and change that into logical
checking, such as checking for a condition, or a null returned from a method
etc, and also consider multiple small Try Catch blocks.

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1166
by: kajol | last post by:
Hi I am creating a setup project in VS.NET, I have "PluginInstaller.msi" installed in my computer, When I am running this setup program in a test machine where no .NET framework and MDAC2.7 is...
1
997
by: LP | last post by:
Hi, I developed a console application that is currently in production. It is scheduled to run every morning (very early morning), to move files from one server to another, update SQL db and then...
2
2486
by: SpookyET | last post by:
How do you pause and resume some work without using Thread.Suspend and Thread.Resume since they are deprecated in .NET 2.0?
4
1856
by: Emmanuel | last post by:
Hi, I have placed a DataList control inside a panel control to obtain a scrollable list using the overflow:auto attribute. The rows in the data list contains and edit LinkButton to enable...
0
2826
by: mike | last post by:
Sound problems resuming from Hibernation I have an MP3 player that plays MP3s off DVD. Uses mci sendstring errreturn = mciSendString("play sound", rs, 128, cb) Been working great for...
13
1728
by: Sheldon | last post by:
Hi. Does anyone know if one can resume a python script at the error point after the error is corrected? I have a large program that take forever if I have to restart from scratch everytime. The...
2
4314
by: jwhite68 | last post by:
The essence of my problem is this. 1. I login to my website with user/password. 2. I select any option, which effectively re-calls index2.php with some additional parameters, to control whats...
2
1102
by: Karim Ali | last post by:
Hi, Simple question. Is it possible in python to write code of the type: ----------------------------- while not eof <- really want the EOF and not just an empty line! readline by line end...
4
1082
by: Jerry West | last post by:
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
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.