|
-
Jan 14th, 2000, 09:45 PM
#1
Thread Starter
Hyperactive Member
When an "On Error Resume Next" is issued, is it only active for the one statement following the error or does it remain active for the entire module?
That is will errors generated by code several lines below the ...Resume Next also resume?
Thanks,
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
-
Jan 14th, 2000, 11:45 PM
#2
PowerPoster
I do beleive it will pick up any subsequent errors and move to the next line. Infact i'm almost positive.
Regards,
------------------
- Chris
[email protected]
If it ain't broke - don't fix it 
-
Jan 14th, 2000, 11:47 PM
#3
Addicted Member
It works for all the code fallowing that statement within a given sub or function. (ie if you have that in a Form_Resize event, when the form resizes so small that controls begin to overlap then an error will rise. But that on error resume next will just ignore it and go on to the next line of code)
------------------
Micah Carrick
http://micah.carrick.com
[email protected]
ICQ: 53480225
-
Jan 15th, 2000, 01:28 AM
#4
Here is a piece of code you can step through and see what happens.
Code:
Dim intMySalary As Integer
Dim intA As Integer
Dim intB As Integer
Const I_WISH = 150000
On Error GoTo ErrorRoutine
intMySalary = I_WISH
MsgBox "I don't get executed"
AfterOverFlow:
MsgBox "Resumed after overflow"
On Error Resume Next
intMySalary = I_WISH
MsgBox "Now I do get executed but intMySalary is " & intMySalary
intA = 25
intB = 60
MsgBox intA + intB
On Error GoTo ErrorRoutine
'This will put us into a loop because I'm raising 25 to the 60th
'power and we get overflow again
intMySalary = intA ^ intB
Exit Sub
ErrorRoutine:
Select Case Err.Number
Case 6 'Overflow
MsgBox "In your dreams!"
Resume AfterOverFlow
Case Else
MsgBox Err.Number & " - " & Err.Description
End Select
------------------
Marty
[This message has been edited by MartinLiss (edited 01-15-2000).]
-
Jan 15th, 2000, 01:33 AM
#5
Thread Starter
Hyperactive Member
Rats! I was afraid of that.
Will On Error Goto 0 disable the resume next?
Here's my dilemma. I have a program that creates individualized spreadsheets for various remote warehouses across the country. Prior to saving the new sheets to the warehouse's network folders, the old sheets are deleted (Killed). At times the warehouse managers are working with the spreadsheets and, since the sheets are open, the Kill command errors out. I used the "on error resume next" to save the new sheet even if the old sheet can't be deleted. But I still need to trap other errors.
Thanks again.
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|