I have derived this code from this post.
And created a simple function for autoclosing msgbox.
Usage:
20 is the delay to close the msgbox
Credits goes to paul and modification from me.
Code:
http://www.vbforums.com/showpost.php?p=3745046&postcount=5
And created a simple function for autoclosing msgbox.
Usage:
Code:
msgboxautoclose("Sample message goes here", MsgBoxStyle.Information, "Title Message", 20)
20 is the delay to close the msgbox
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte,
ByVal bScan As Byte, _
ByVal dwFlags As Byte, _
ByVal dwExtraInfo As Byte)
Private Const VK_RETURN As Byte = &HD
Private Const KEYEVENTF_KEYDOWN As Byte = &H0
Private Const KEYEVENTF_KEYUP As Byte = &H2
Public Sub msgboxautoclose(ByVal Message As String, Optional ByVal Style As MsgBoxStyle = Nothing, Optional ByVal title As String = Nothing, Optional ByVal delay As Integer = 5)
Dim t As New Threading.Thread(AddressOf closeMsgbox)
t.Start(delay) '5 second default delay
MsgBox(Message, Style, title)
End Sub
Private Sub closeMsgbox(ByVal delay As Object)
Threading.Thread.Sleep(CInt(delay) * 1000)
AppActivate(Me.Text)
keybd_event(VK_RETURN, 0, KEYEVENTF_KEYDOWN, 0)
keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0)
End Sub
Credits goes to paul and modification from me.