“否”选择将我带到错误的下一个msgbox输入中

问题描述 投票:0回答:1
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“你有FEHB ...”时,如果我选择“ No”,我希望它继续前进到新的msgbox “请在此处首字母表示您没有...”。如果答案是“是”,那么我想转到msgbox“您要终止”吗,另一个是/否。从那里开始,如果他们选择“否”,则可能不想在另一个框中终止。

ms-access msgbox
1个回答
0
投票

下面是一些VBA代码,显示了应如何进行。在执行此类操作时,通常有助于在纸上画出逻辑过程,并且在对If语句进行编码时,总是缩进每个嵌套级别以保持可读性。

Sub sMsg()
    Dim strInput As String
    If vbYes = MsgBox("Do you have FEHBB?", vbYesNo) Then
        If vbYes = MsgBox("Do you want to terminate", vbYesNo) Then

        Else    '   No they don't want to terminate
            If vbYes = MsgBox("Yes/No for next choice", vbOKOnly) Then

            Else

            End If
        End If
    Else    ' do not have FEHBB
        strInput = InputBox("Please initial here")
    End If
End Sub

问候,

© www.soinside.com 2019 - 2024. All rights reserved.