Solved

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

Posted on 2007-12-05
6
5,067 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

733 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