Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #742

Error handling problem

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.sovam.com!news.mi.ras.ru!spln!extra.newsguy.com!newsp.newsguy.com!news7
From a@b.com
Newsgroups comp.lang.basic.visual.misc
Subject Error handling problem
Date Tue, 07 Feb 2012 14:55:37 -0800
Organization NewsGuy - Unlimited Usenet $19.95
Lines 54
Message-ID <tk93j79l1o14ffsp3q62mg3pj512i7eo7t@4ax.com> (permalink)
NNTP-Posting-Host pfe9098d1085d36f0b63b94a36b3af2cc7db97abffb03db0d.newsdawg.com
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Newsreader Forte Agent 4.2/32.1118
Xref x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:742

Show key headers only | View raw


In the following code the first time an error occurs in (code 2) the 
error handler goes to Err_Label2.
But on the next loop iteration if an error occurs in block (code 2) 
neither of the error handlers are called.
The error is thrown back to the caller that called MyFunction.
It is as if on the second iteration the error handler 
"On Error Goto 0" is in effect.

Can anyone reproduce and/or explain this behavior?


Function MyFunction()

   Dim ErrNum 

   On Error Goto Err_Label

   (code 1 - read recordset MyRs)

   MyRs.MoveFirst
   Do Until MyRs.EOF

      On Error Goto Err_Label2

      (code 2)

Err_Label2:
      ErrNum =  Err.Number
      Err.Clear

      On Error Goto Err_Label

      If ErrNum <> 0 Then
        (do something)
      Else
        (do something else)
      End If

      MyRs.MoveNext

   Loop

Exit_Label:
   (cleanup code)

   Exit Function

Err_Label:
   (code)
   Resume Exit_Label

End Function
  

Back to comp.lang.basic.visual.misc | Previous | NextNext in thread | Find similar


Thread

Error handling problem a@b.com - 2012-02-07 14:55 -0800
  Re: Error handling problem Deanna Earley <dee.earley@icode.co.uk> - 2012-02-08 09:18 +0000
    Re: Error handling problem a@b.com - 2012-02-08 11:22 -0800

csiph-web