2017-06-02 75 views
0

我有一个问题,我无法得到我的头。从MsgBox捕获输入

我有一个窗体,我有MsgBox告诉用户,如果一些箱子丢失的信息,然后询问他们是否要继续。

当用户按下Yes时,用户窗体的值将被传送到表单中。但是,当用户选择否时,值仍然传输...

如何使MsgBox关闭,当用户选择No,没有值传递?

+0

你可以发布你的代码吗? – avb

+0

这里是[用于MsgBox函数Microsoft文档](https://msdn.microsoft.com/en-us/library/aa445082(V = vs.60)的.aspx)。 –

回答

0

这是你想要的吗?

Sub Sample() 
    Dim Ret As Variant 

    Ret = MsgBox("Blah Blah", vbQuestion + vbYesNo) 

    If Ret = vbYes Then 
     MsgBox "You pressed `Yes`" '<~~ Code to transfer to the sheet here 
    ElseIf Ret = vbNo Then 
     MsgBox "You pressed `No`" 
    End If 
End Sub 
0

如果你想记录提交到纸张上,只有当用户在窗口MSGBOX点击“是”,你可以尝试这样的事情......

更换MSGBOX按你的需求。

Dim Ans As Long 
Ans = MsgBox("You didn't fill all the information." & vbNewLine & vbNewLine & "Do you want to continue?", vbQuestion + vbYesNo, "Confirm Please!") 
If Ans = vbYes Then 
    'Code to submit the records onto the Sheet 
End If