Msgbox VBA + minuterie

Dergoshine -  
eriiic Posted messages 24581 Registration date   Status Contributeur Last intervention   -
Hello,

I would like that when you click on my button on my Excel sheet, a msg box opens, asks the user to wait and closes after a predefined period of time before displaying a result.

If possible, I would like the user to see the timer on the msg box (for example, the seconds counting down) and that after the time has elapsed, the msg box closes by itself to display the result.

Thank you in advance for your help.

3 réponses

Fallentree Posted messages 2445 Status Membre 210
 
you shouldn't dream, you won't have interaction in a msgbox ...
you need to open a new window with a one-second timer to display the time and a test on the cumulative ...
it's simple, but well, I don't know vb that well anymore. it's click and load events that need to be managed ...
0
pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 772
 
Hello,
Is it just to force the user to wait, or do you want a procedure to take place during the countdown?
--
Best regards,
Franck P
0
Dergoshine
 
It's just to keep him waiting, no procedure during the wait.
0
pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 772
 
Temporary MsgBox:
Sources Code:
CreateObject("Wscript.shell").Popup "My Text", 3, "The Title"
3 = 3 seconds.....

To display a countdown, you should no longer use a MsgBox, but create one yourself using UserForms. Sources and the code to use:
Dim i As Integer With UserForm1 .Show 0 For i = 10 To 0 Step -1 Application.Wait Now + TimeValue("00:00:01") .Label1 = i .Repaint Next End With

example
0
Dergoshine
 
Ok, I tested the first code, the window doesn't disappear after 3 seconds, it doesn't disappear at all actually, you have to press OK to make it go away...
0
pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 772
 
try again ... It did that to me the first time too. This code may require saving the workbook...
0
Dergoshine
 
I created a function in the module, and that's where I put the code you mentioned. Then I took my button and did Call + name of my created function, but it doesn't work.
0
eriiic Posted messages 24581 Registration date   Status Contributeur Last intervention   7 281
 
Good evening,

pijaku had to be absent and asked me to take over your question.
Neither does his file work as expected on my end (2003).

Here is another proposal largely inspired by Jacques Boisgontier's website:
http://boisgontierjacques.free.fr/pages_site/formulairebases.htm#barreAttente

Time is ticking by, but for that, the dialog box must be non-modal.
This implies that the user can use/edit the workbook while it is displayed.
Apart from adding maximum protection to the sheets before displaying the dialog box and removing that protection after it is closed, I don't see any other solutions.
Otherwise, give up on showing the time. Unless someone knows how to make a dialog box active... I haven't found it and it's getting late ;-)

http://www.cijoint.fr/cjlink.php?file=cj201108/cijqMbBdKe.xls

eric
0