Retry on exception

K

kimiraikkonen

Hi,
It may a simple question but i needed to verify. I hava a for-next
loop and when an exception occurs, i don't want my program to the jump
out of try-catch block and i want it to retry the operation again.

Here is what i meant:

Try

Dim x as integer
For x=0 to 10
<Codeline1>
Next

Catch
'Error message
<Codeline2>

End Try

'Operation ended
<Codeline3>


At this code when the program processing for example 3rd (x) item in
for-next loop and if an exception is thrown, <Codeline2> is executed
as well, then it jumps to <Codeline3>.

My aim is that when an exception is thrown on any for-next (x) item,
the program must ignore it or notice as messagebox then "continue"
processing operation till it reaches the end of for-next loop (x=10)
instead of jumping outside try-catch block and interrupting operation.

How can i do this?

Thanks!
 
C

Cor Ligthert[MVP]

Kimi,

As I understand you well, then normally I would set the try and catch
complete inside the for loop.

Cor
 
T

Teemu

kimiraikkonen said:
Hi,
It may a simple question but i needed to verify. I hava a for-next
loop and when an exception occurs, i don't want my program to the jump
out of try-catch block and i want it to retry the operation again.

On Error Goto...
On Error Resume

Try looking for these keywords.

-Teemu
 
K

kimiraikkonen

Kimi,

As I understand you well, then normally I would set the try and catch
complete inside the for loop.

Cor

Thanks Teemu and Cor, i put try-catch block inside my loop and works.
 

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