반응형
유효성 검사 시 추가 실행을 중지하는 매크로
나는 있습니다method-A()
여러 가지 방법으로 호출됩니다.
메소드-A의 조건으로, 나는 매크로를 종료해야 합니다.
나는 한 가지 옵션을 보았습니다.Exit sub
하지만 이것은 단지 전류를 빠져나갈 것입니다.sub ie:method-A()
그리고 남은 프로그램은 계속됩니다.
이 일을 어떻게 처리해야 할지.
Sub mainMethod()
method-A()
end Sub
Sub method-A()
if (true) Then
'Terminate the macro. that is exit method-A() and also mainMethod()
end Sub
댓글 후 편집 : 그냥 사용end
모든 코드를 종료할 수 있습니다.
Sub mainMethod()
method_A()
end Sub
Sub method-A()
if (true) Then End
'Terminate the macro. that is exit method-A() and also mainMethod()
end Sub
원본 답변:다음 코드에 따라 메인 메서드를 종료하려면 메서드 A를 함수로 만들고 이 함수를 FALSE로 반환하기만 하면 됩니다.
Sub mainMethod()
'Run the custom function and if it returns false exit the main method
If Not method_A Then Exit Sub
'If method_A returns TRUE then the code keeps going
MsgBox "Method_A was TRUE!"
End Sub
Function method_A() As Boolean
Dim bSomeBool As Boolean
'Code does stuff
bSomeBool = True
'Check your condition
If bSomeBool Then
'Set this function as false and exit
method_A = False
Exit Function
End If
'If bSomeBool = False then keep going
End Function
언급URL : https://stackoverflow.com/questions/14827273/terminating-macro-from-executing-further-on-validation
반응형
'it-source' 카테고리의 다른 글
C에서 포인터로 2D 배열을 전달하는 방법은 무엇입니까? (0) | 2023.06.15 |
---|---|
런타임에 메서드가 정의된 위치를 찾는 방법은 무엇입니까? (0) | 2023.06.15 |
rreplace - 문자열에서 마지막으로 나타나는 식을 바꾸는 방법은 무엇입니까? (0) | 2023.06.15 |
Angular 빌드에서 'es6'(또는 접미사가 전혀 없음)가 아닌 'es5'와 'es2015'로 파일을 만드는 이유는 무엇입니까? (0) | 2023.06.10 |
GoogleSignIn, AdMob으로 인해 앱 제출 시 "앱이 사용 설명 없이 개인 정보에 민감한 데이터에 액세스 시도" iOS 10 GM 릴리스 오류 (0) | 2023.06.10 |