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

筅森魡賤 提交于 2020-12-12 11:12:11

问题


In VB6 I am trying to find out how to get the input from the user in a MsgBox

Here is my code:

Dim myAnswer As Integer

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

The MsgBox comes up with an ok and cancel button but I don't know how to tell whether or not they clicked ok or cancel.


回答1:


Here:

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

There are 7 constants for the result returned by a MsgBox function:

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

References:

  • MsgBox Function.


来源:https://stackoverflow.com/questions/50478148/how-do-i-know-the-input-i-get-from-a-msgbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!