Msgboxes基于条件语句遵循两个不同的path

我有一种感觉,我已经结束了复杂的事情。 下面的脚本是我想要做的基础。 我遇到的问题是与msgboxes。

基本上,我需要一个msgbox的条件B失败(和退出)和msgbox成功的循环完成。 所以,他们每个人都需要遵循不同的条件,但我不知道该怎么做?

For i = 1 To Val(days) If hasrun = False Then If condition A <> 0 Then do nothing ElseIf condition A = 0 Then Do this... End If If condition B <> 0 Then Exit For ElseIf condition B = 0 Then Do that… End If Do this other code... hasrun = True Next i MsgBox "Script exited because condition B already existed" MsgBox "Script finished successfully." End if 

你可以只logging一个标志variables发现问题的事实:

 Dim blnBFail As Boolean For i = 1 To Val(days) If hasrun = False Then If condition A <> 0 Then do nothing ElseIf condition A = 0 Then Do this... End If If condition B <> 0 Then blnBFail = True Exit For ElseIf condition B = 0 Then Do that… End If Do this other code... hasrun = True Next i If blnBFail then MsgBox "Script exited because condition B already existed" Else MsgBox "Script finished successfully." EndIf End if