PDA

Click to See Complete Forum and Search --> : Ok, I did the prerequisite help search bt am still unsure about on error resume next


Al Smith
Jan 14th, 2000, 08:45 PM
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:asmith3914@aol.com
asmith@spxateg.com">asmith3914@aol.com
asmith@spxateg.com</A>

chrisjk
Jan 14th, 2000, 10:45 PM
I do beleive it will pick up any subsequent errors and move to the next line. Infact i'm almost positive.

Regards,

------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)

MicahCarrick
Jan 14th, 2000, 10:47 PM
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
micah@carrick.com
ICQ: 53480225

MartinLiss
Jan 15th, 2000, 12:28 AM
Here is a piece of code you can step through and see what happens. 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).]

Al Smith
Jan 15th, 2000, 12:33 AM
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:asmith3914@aol.com
asmith@spxateg.com">asmith3914@aol.com
asmith@spxateg.com</A>