Reprén la sentència

Resets error information and indicates what to execute next.

Sintaxi:

Reprendre el diagrama d'extractes


     Resume [ [0] | label | Next ]
   

Paràmetres :

0 Reinicia la informació d'error i torna a executar la instrucció que ha causat l'error. 0 és opcional.

label: Resets error information and resumes execution at the specified label of the current subroutine.

Next Reinicia la informació d'error i executa la instrucció que segueix a la que ha causat l'error.

Error information is built with Erl, Err and Error$ functions.

tip

Using Resume to reset error information prevents the propagation of the handled condition to calling routines.


Codis d'error

20 Continua sense error

Exemples:

Typical error handling routines are: alerting the user, fixing the error, logging error information or re-throwing custom errors that provide explanations with resolution instructions. Use Resume label when requiring such mechanisms.


      Sub Error_Handling
      try: On Error GoTo catch
          ' el codi de la rutina va ací
          Error 91 ' example error
      finally:
          ' routine cleanup code goes here
          Exit Sub
      catch:
          Print Erl, Err, Error$
          Resume finally
      End Sub ' Error_Handling
    

Use Resume Next, for example, when reporting anomalies encountered for an iterating process that must not be interrupted. In which case multiple handling routines may be required.


      Sub Iteration
          planets = Array("☿","♀","♁","♂","♃","♄","⛢","♆")
      try:
          On Error GoTo ReportAndProcessNext
          For ndx = -3 To 11 Step 1
              MsgBox planets(ndx)
          Next
          On Error GoTo 0 ' Stop error catching
      finally:
          Exit Sub
      ReportAndProcessNext:
          Print "Error "& Err &" at line "& Erl &" - "& Error$
          Resume Next
      End Sub ' Iteration
    
warning

Using Resume without parameters to re-execute the faulty instruction can fit certain situations. However that may cause a never ending loop.


Ens cal la vostra ajuda!