Solved

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

Posted on 2007-12-05
6
4,981 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
ID: 20417694
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
ID: 20417708
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
ID: 20417905
Then,When do you want messagebox to get disappear?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 100 total points
ID: 20418058
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
ID: 20418302
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
ID: 20418579
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

919 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

12 Experts available now in Live!

Get 1:1 Help Now