Solved

Visual Basic Show Message Box and NOT WAIT till user press ONE

Posted on 2007-12-05
6
4,958 Views
Last Modified: 2013-12-20
Hello

I have a code like this:

Private Sub Form_click()
MessageBox 0, "Test", App.Title
Me.Caption = "HERE"
End Sub

I want me.caption = "HERE" to be called right after messagebox shown to user.

But now it waits till user press OK button in msgbox. I don't want to wait. Please advice about it. I tried MessageBox with APi, but still same.

I don't want to wait to user to press a button on messagebox, I just want to show messagebox and keep code running.

Thanks from now!
0
Comment
Question by:CSecurity
6 Comments
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 50 total points
Comment Utility
Message boxes are modal dialogs, that means that it doesn't return the control to the calling function until it closes.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
you can try to call directly the WinAPI's MessageBox() function:


Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
 

Sub Non_Modal_Msgbox(message as String, caption as String)

      Call MessageBox(0&, message, caption, 0&)

End Sub 

Open in new window

0
 
LVL 5

Expert Comment

by:abith
Comment Utility
Then,When do you want messagebox to get disappear?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 100 total points
Comment Utility
The better way to do that is to create your own msgbox. You have also some extended msgbox's examples that you can try to use  but it will give some work and I really don't know if it works.

http://vbnet.mvps.org/code/comdlg/messageboxex.htm
http://vbnet.mvps.org/code/hooks/messageboxhooktimerapi.htm
0
 
LVL 17

Accepted Solution

by:
wobbled earned 350 total points
Comment Utility
You could just create a userform and control that from a module.

eg. userform called frmMsg


In a module have the code

dim objFrm as object

set objFrm = new frmMsg

with objFrm
        .Caption = "Caption Text"
        .Show
end with

'more code

What you can do then is have a timer put on the form, this can then be called from the module to begin the timer and run it until it reaches a set number of seconds etc
This can then close the form and return you back to module of code

0
 
LVL 4

Expert Comment

by:J1H1W1
Comment Utility
This would be a good point to start interopting with VB.Net code.  Then you could simply put the message box on a background worker thread.  To do the same in VB6 use the Windows API to start a new thread and call the message box from it.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now