"No" 选择将我带到错误的下一个 msgbox 输入
"No" selection takes me to the wrong next msgbox input
If vbYes = MsgBox("Do you have Federal Employee Health Benefits (FEHBB), such as Blue Cross Blue Shield?", vbYesNo + vbQuestion) Then
End If
If vbYes = MsgBox("Would you like to terminate/suspend your Federal Employee Health Benefits (FEHB) while on orders?", vbYesNo + vbQuestion) Then
FEHBCancel = InputBox("Please initial here to cancel/suspend your FEHB.")
Else
NoFEHB = InputBox("Please initial here indicating that you do not have Federal Employee Health Benefits.")
End If
上面的内容似乎 运行 通过了,但是我现在 运行 遇到的问题是当我询问第一个 msgbox "Do you have FEHB..." 是否 select "No",我希望它移动到一个新的 msgbox "please initial here indicating that you do not have..."。如果答案是 "YES",那么我想转到 msgbox "do you want to terminate",另一个 Yes/No msgbox。从那里开始,如果他们 select "no" 他们不想终止,则可能是另一个框。
下面是一些 VBA 代码,说明如何完成此操作。做这种事情的时候,把逻辑过程画在一张纸上,写If语句的时候,总是缩进每一层嵌套,以保持可读性。
Sub sMsg()
Dim strTerminate As String, strPayFor As String, strNoFEHBB As String
If vbYes = MsgBox("Do you have FEHBB?", vbYesNo) Then
If vbYes = MsgBox("Do you want to terminate", vbYesNo) Then
strTerminate=InputBox("Please initial to terminate")
Else ' No they don't want to terminate
strPayFor=InputBox("Please initial to pay")
End If
Else ' do not have FEHBB
strNoFEHBB = InputBox("Please initial here")
End If
End Sub
此致,
If vbYes = MsgBox("Do you have Federal Employee Health Benefits (FEHBB), such as Blue Cross Blue Shield?", vbYesNo + vbQuestion) Then
End If
If vbYes = MsgBox("Would you like to terminate/suspend your Federal Employee Health Benefits (FEHB) while on orders?", vbYesNo + vbQuestion) Then
FEHBCancel = InputBox("Please initial here to cancel/suspend your FEHB.")
Else
NoFEHB = InputBox("Please initial here indicating that you do not have Federal Employee Health Benefits.")
End If
上面的内容似乎 运行 通过了,但是我现在 运行 遇到的问题是当我询问第一个 msgbox "Do you have FEHB..." 是否 select "No",我希望它移动到一个新的 msgbox "please initial here indicating that you do not have..."。如果答案是 "YES",那么我想转到 msgbox "do you want to terminate",另一个 Yes/No msgbox。从那里开始,如果他们 select "no" 他们不想终止,则可能是另一个框。
下面是一些 VBA 代码,说明如何完成此操作。做这种事情的时候,把逻辑过程画在一张纸上,写If语句的时候,总是缩进每一层嵌套,以保持可读性。
Sub sMsg()
Dim strTerminate As String, strPayFor As String, strNoFEHBB As String
If vbYes = MsgBox("Do you have FEHBB?", vbYesNo) Then
If vbYes = MsgBox("Do you want to terminate", vbYesNo) Then
strTerminate=InputBox("Please initial to terminate")
Else ' No they don't want to terminate
strPayFor=InputBox("Please initial to pay")
End If
Else ' do not have FEHBB
strNoFEHBB = InputBox("Please initial here")
End If
End Sub
此致,