我如何知道从 MsgBox 获得的输入?

How do I know the input I get from a MsgBox?

在 VB6 中,我试图了解如何在 MsgBox 中获取用户的输入

这是我的代码:

Dim myAnswer As Integer

myAnswer = MsgBox("Do you want to buy this upgrade?", vbOKCancel, "Upgrade Description")

MsgBox 出现了一个确定和取消按钮,但我不知道如何判断他们是否单击了确定或取消。

这里:

Dim myAnswer As Integer
myAnswer = MsgBox("Do you want to buy this upgrade?", vbOKCancel, "Upgrade Description")

If myAnswer = vbOK Then
    MsgBox "You clicked 'OK'."
ElseIf myAnswer = vbCancel Then
    MsgBox "You clicked 'Cancel'."
' ...
End If

MsgBox函数返回的结果有7个常数:

Constant    Value   Description
vbOK        1       OK
vbCancel    2       Cancel
vbAbort     3       Abort
vbRetry     4       Retry
vbIgnore    5       Ignore
vbYes       6       Yes
vbNo        7       No

参考文献: