在VB6中,我试图找出如何从MsgBox中获取用户的输入
这是我的代码:
Dim myAnswer As Integer
myAnswer = MsgBox("Do you want to buy this upgrade?", vbOKCancel, "Upgrade Description")
MsgBox出现了一个确定和取消按钮,但我不知道如何判断他们是否点击确定或取消。
答案 0 :(得分:6)
下面:
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