영업 : 매번 오류를 해결해야합니까? 또는 End Sub에서 오류 처리기를 계속 진행하는 대신 Sub Subtitle을 종료해야합니까?
오류를 삭제하면 무엇을 의미합니까?
일반적으로 절차는 이러한 방식으로
public sub myProcedure()
on error goto e:
'statements that could raise error
exit sub
e:
Log err.Number, err.Description, "error occurred in myProcedure"
end sub
또는
오류 처리기를 추가하지 않도록 선택할 수로 작성되었습니다. 이 경우 오류는 호출자 (또는 처리되는 프로 시저)로 전달됩니다.
& 귀하의 기대치를 달성하고자하는 샘플 코드를 게시하십시오.
편집 : 여기 당신이 게시 한 코드는 특정 예와
Public Sub SubA()
On Error Goto ProcError
' other code
MsgBox FuncA()
exit sub 'put exit sub otherwise it will execute the line below, even if no error
ProcExit:
'this statement will get executed after the error msgbox is shown
msgbox "Reached ProcExit"
Exit Sub
ProcError:
MsgBox Err.Description 'catch the error and show the msgbox
'error is cleared the point it reaches ProcError
'Resume ProcExit acts as goto, to execute any statements after the error is handled
Resume ProcExit
End Sub
질문을 나타내는 코드를 게시하십시오. – bugmagnet
샘플 코드와 같이 어디에서 오류를 지우시겠습니까? – shahkalpesh
글쎄, 나는 "Resume ProcExit"이 Err.Clear와 같은 일을한다고 읽었다. 하지만 내가 게시 한 코드가 왜 그런가요? 왜 "ProcExit 재개"인가? 잘못을 치우려면? 동일한 프로 시저가 다음의 잠재적 인 오류를 처리 할 수 있도록? –