Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error handler resume
I have a sub in which I call an error handler if certain requirements are
met. I call the error handler and give a message to the user but I want to continue where the error was. Now it contnues in the main sub for some reason. Code for error handler: Handler: Select Case Err.Number Case 600 ........ If Err.Number = 666 Then Resume Next End If end select and in the sub I call the error handler for that particukar error using: Err.Raise 666 Please help me out here! Many thanks in advance! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error handler resume
Arne,
Surely you don't the If as you have the select case Handler: Select Case Err.Number Case 600 'do something...... Case 666 Msgbox "666 error" Resume Next Case Else msgbox "Give Up" End select NickHK "Arne Hegefors" ... I have a sub in which I call an error handler if certain requirements are met. I call the error handler and give a message to the user but I want to continue where the error was. Now it contnues in the main sub for some reason. Code for error handler: Handler: Select Case Err.Number Case 600 ....... If Err.Number = 666 Then Resume Next End If end select and in the sub I call the error handler for that particukar error using: Err.Raise 666 Please help me out here! Many thanks in advance! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error handler resume
You case statement appears screwed up. why shift to an if statement.
Anyway, this worked for me: Sub Main() On Error GoTo ErrHandler Test For i = 1 To 10 j = j + 1 Next i Exit Sub ErrHandler: MsgBox "In Main Error Handler" End Sub Sub Test() On Error GoTo Handler Err.Raise 666 MsgBox "Line After error 666" Handler: Select Case Err.Number Case 600 MsgBox "Error is 600" Case 666 MsgBox "Error is 666" Resume Next End Select End Sub -- Regards, Tom Ogilvy "Arne Hegefors" wrote: I have a sub in which I call an error handler if certain requirements are met. I call the error handler and give a message to the user but I want to continue where the error was. Now it contnues in the main sub for some reason. Code for error handler: Handler: Select Case Err.Number Case 600 ....... If Err.Number = 666 Then Resume Next End If end select and in the sub I call the error handler for that particukar error using: Err.Raise 666 Please help me out here! Many thanks in advance! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error handler resume
Hell NickHK. I tried your code and I got the same type of problem. After the
Error 666 the code gives me "Give up". Now I dont know how to do this but I just want to call the error handler from my sub. In the error handler give the user some simple message and then keep going in the sub as if nothing happend. Is that impossible? Shall I just stick with a message box in the sub? Please help me out here! Thanks very much! PS Tom I really appreciate your answer but I did not really understand what it meant. Sorry... Thanks very much. "NickHK" skrev: Arne, Surely you don't the If as you have the select case Handler: Select Case Err.Number Case 600 'do something...... Case 666 Msgbox "666 error" Resume Next Case Else msgbox "Give Up" End select NickHK "Arne Hegefors" ... I have a sub in which I call an error handler if certain requirements are met. I call the error handler and give a message to the user but I want to continue where the error was. Now it contnues in the main sub for some reason. Code for error handler: Handler: Select Case Err.Number Case 600 ....... If Err.Number = 666 Then Resume Next End If end select and in the sub I call the error handler for that particukar error using: Err.Raise 666 Please help me out here! Many thanks in advance! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error handler resume
Arne,
This works for me: Private Sub CommandButton1_Click() Dim i As Long On Error GoTo Handler For i = 1 To 100 If i Mod 50 = 0 Then Err.Raise 666 End If Next Exit Sub Handler: Select Case Err.Number Case 600 'do something...... Case 666 MsgBox "666 error" Resume Next Case Else MsgBox "Give Up" End Select End Sub NickHK "Arne Hegefors" ... Hell NickHK. I tried your code and I got the same type of problem. After the Error 666 the code gives me "Give up". Now I dont know how to do this but I just want to call the error handler from my sub. In the error handler give the user some simple message and then keep going in the sub as if nothing happend. Is that impossible? Shall I just stick with a message box in the sub? Please help me out here! Thanks very much! PS Tom I really appreciate your answer but I did not really understand what it meant. Sorry... Thanks very much. "NickHK" skrev: Arne, Surely you don't the If as you have the select case Handler: Select Case Err.Number Case 600 'do something...... Case 666 Msgbox "666 error" Resume Next Case Else msgbox "Give Up" End select NickHK "Arne Hegefors" ... I have a sub in which I call an error handler if certain requirements are met. I call the error handler and give a message to the user but I want to continue where the error was. Now it contnues in the main sub for some reason. Code for error handler: Handler: Select Case Err.Number Case 600 ....... If Err.Number = 666 Then Resume Next End If end select and in the sub I call the error handler for that particukar error using: Err.Raise 666 Please help me out here! Many thanks in advance! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error handler resume
You said:
Now it continues in the main sub for some reason. Usually MAIN is used to describe a calling routine that calls a subroutine. so I tried to recreate you situation and show how the the two interact. In any event, my example is not much different from Nick's examples. It is unclear why you don't understand them. Perhaps you need to type Resume in a module, highlight it and hit F1 to get the help that explains how resume works. -- Regards, Tom Ogilvy "Arne Hegefors" wrote: Hell NickHK. I tried your code and I got the same type of problem. After the Error 666 the code gives me "Give up". Now I dont know how to do this but I just want to call the error handler from my sub. In the error handler give the user some simple message and then keep going in the sub as if nothing happend. Is that impossible? Shall I just stick with a message box in the sub? Please help me out here! Thanks very much! PS Tom I really appreciate your answer but I did not really understand what it meant. Sorry... Thanks very much. "NickHK" skrev: Arne, Surely you don't the If as you have the select case Handler: Select Case Err.Number Case 600 'do something...... Case 666 Msgbox "666 error" Resume Next Case Else msgbox "Give Up" End select NickHK "Arne Hegefors" ... I have a sub in which I call an error handler if certain requirements are met. I call the error handler and give a message to the user but I want to continue where the error was. Now it contnues in the main sub for some reason. Code for error handler: Handler: Select Case Err.Number Case 600 ....... If Err.Number = 666 Then Resume Next End If end select and in the sub I call the error handler for that particukar error using: Err.Raise 666 Please help me out here! Many thanks in advance! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
On Error {...} Resume Next | Excel Programming | |||
Form Err.Raise error not trapped by entry procedure error handler | Excel Programming | |||
On Error Resume Next | Excel Programming | |||
On Error Resume Next | Excel Programming | |||
ON ERROR RESUME NEXT | Excel Programming |