Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Error handling

I am quite new to VBA programming and I have come across a problem when
dealing with errors. Comming from a C++ background I am most familiar with
exceptions and I was wondering if there is some way to "rethrow" an erro once
it has been handled? Something like:

Sub Foo()
On Error GoTo E:
Bar
Baz
Exit Sub

E:
If Err.Number = 11 Then
Resume Next
Else
ReThrow Err
End If
End Sub

Imagine for example that sometimes Bar will try to divide by zero, and if
that happens it is safe to resume and execute Baz. But if some other kind of
error should happen I do not want to handle it here.

I know that I can use 'Error Err.Number' or Err.Raise to "create" a new
error in the else-block, but while developing it would be nice to have the
original error to simplify debugging (since the debugger can show me where
the error occurred).

--
Erik Wikström
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO Error Handling Fred Smith[_3_] Excel Programming 0 June 18th 07 04:11 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Handling Steph[_6_] Excel Programming 1 August 25th 05 03:44 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error handling Tim C Excel Programming 1 October 7th 03 10:00 PM


All times are GMT +1. The time now is 01:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"