Solved

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

Posted on 2007-12-05
6
5,041 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 39
Copy a row 12 64
How to compare ms sql hashbytes results within vb6 5 85
Problem to line 23 55
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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