|
修改一下,把wType定义成vbMsgBoxStyle,这样可以提示输入VBA里的MsgBox常数了。
Private Declare Function MsgBoxEx Lib "user32" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal wType As VbMsgBoxStyle, _
ByVal wlange As Long, _
ByVal dwTimeout As Long) As Long
Private Sub TestMsgboxEx()
Dim ret As Long
ret = MsgBoxEx(0, "请选择", "两秒后自动关闭", vbYesNo + vbInformation, 1, 2000)
If ret = 32000 Then
Debug.Print "超时关闭"
ElseIf ret = vbYes Then
Debug.Print "选择Yes"
ElseIf ret = vbNo Then
Debug.Print "选择No"
End If
End Sub |
|