Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msgbox that disappears automatically after certain time

Tags:

vb.net

msgbox

Is there any type of msgbox in vb.net that gives a message and it disappears automatically after a certain time? Or is there any method to hide the msgbox, without user's clicking OK?

like image 782
Furqan Sehgal Avatar asked Jun 28 '11 16:06

Furqan Sehgal


2 Answers

Linendra Soni's answer is good, but it may or may not work in the newer versions of Windows and/or Excel.

This works perfectly in the newer versions:

Function MessageTimeOut(sMessage As String, sTitle As String, iSeconds As Integer) As Boolean
    Dim Shell
    Set Shell = CreateObject("WScript.Shell")
    Shell.Run "mshta.exe vbscript:close(CreateObject(""WScript.shell"").Popup(""" & sMessage & """," & iSeconds & ",""" & sTitle & """))"
    MessageTimeOut = True
End Function

Use it like this:

Sub Example()
    Dim chk As Boolean
    chk = MessageTimeOut("Hello!", "Example Sub", 1) 'if chk returned FALSE that means the function was not executed successfully
End Sub

or

Sub Example()
    Call MessageTimeOut("Hello!", "Example Sub", 1) 'you don't need to get the output of the function
End Sub

Output:

enter image description here

like image 172
Ibo Avatar answered Oct 21 '22 13:10

Ibo


You Can use

CreateObject("WScript.Shell").Popup("Welcome", 1, "Title")

this msgbox will close automatically after 1 second

like image 30
Linendra Soni Avatar answered Oct 21 '22 12:10

Linendra Soni