有API替代品!在模塊的上聲明此功能:
#If VBA7 Then
Public Declare PtrSafe Function ModelessMsgBox Lib "User32" Alias "MessageBoxA" (Optional ByVal hWnd As Long, _
Optional ByVal prompt As String, _
Optional ByVal title As String, _
Optional ByVal buttons As Long) As Long
#Else
Public Declare Function ModelessMsgBox Lib "User32" Alias "MessageBoxA" (Optional ByVal hWnd As Long, _
Optional ByVal prompt As String, _
Optional ByVal title As String, _
Optional ByVal buttons As Long) As Long
#End If
而且使用這樣的:
Call ModelessMsgBox(prompt:="MsgBox!!!!", buttons:=vbYesNo)
然而,這MSGBOX停止執行代碼(當模式窗體沒有,你惜敗使用另一種垃圾組全局/靜態變量和/或剿事件只是爲了控制執行流程中),所以它可以這樣使用:
If ModelessMsgBox(prompt:="MsgBox!!!!", buttons:=vbYesNo) = vbYes Then
'do smth
Else
'do smth else
End If
更多here