vba msgbox函数显示的消息框,不点击按钮鼠标指针一直处于忙碌状态
发布网友
发布时间:2022-04-23 21:47
我来回答
共1个回答
热心网友
时间:2023-10-10 21:47
使用windows api中的MsgBoxEx函数,可以让消息框自动关闭:
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