Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set delay in VB6.

Status
Not open for further replies.

Ergo30

IS-IT--Management
Jun 22, 2007
10
GB
I'm trying to set a pause in my code so that when someone clicks command button 1 it saves their data into a text file and then brings up a msgbox telling them that the data has been logged. After about 3 secs I need to box to close down automatically and leave the form up to enter more data.

I have tried using 'Next' and counting values up until they reach a set figure but it still does not pause the message box.

Has anyone got any ideas? Many thanks if you do.

Simon
 
Please don't do this.

From a user perspective, you probably don't want to have too many message box's popping up all over the place. In my opinion, message boxes should be used when there is a problem or the user MUST make a decision on an action.

Instead, I would suggest that you add a label to your form. Set the caption to an empty string. Also add a timer to your form, with an interval of 3000 (which is 3 seconds). Then, disable the timer.

Finally, when you save your data to the text file, set the caption of the label to "Data logged", set the enabled property of the timer to true. Then, in the timer event, clear the contents of the label and disable the timer.

This way, there will be no message box, but you will still be able to use the label to show useful information to the user. With the label approach, they won't have to click the box or wait 3 seconds in order to continue doing things.

Make sense? If not, I will explain more.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
George

Thanks again for answering another of my questions, I will on later to try your suggestions so I will feed back here. I agree with you on the message box thing but could not think of another way, I will give yours a try.

Cheers

Simon
 
If it's a single fixed signal to the user you could simply set the Caption to some literal value and toggle it's Visible property too.

Even better might be to use a status bar. This gives you several options for message display, and if you create a clever one you can even display the more important messages with a colorful icon similar to those used with various MsgBox buttons bitmask parameter values (vbCritical, vbExclamation, vbInformation, etc.).

Even a simple Label control with a border works well for many purposes though, set close to the form's bottom border.

The status message can be set to time out or accept a click on it to "erase" earlier for those who won't wait 3 seconds.
 
Just to test the concept, open a project. Place 2 forms on it. On the second form, put a label with your message, preferably in a large (say 72 point) font. On the first form, put a timer control.

Set the timer's enabled property to true and its interval property to 1000. In the timer event, place the following code:
Code:
Private Sub Timer1_Timer()
Form2.Visible = Not Form2.Visible
Beep
End Sub
Run the code. When you've found it sufficiently annoying, come up with something less intrusive. :)

Bob
 
Thanks to all for you input on this one. I'm getting a strange feeling that I should not be using a pop up message box:)

Thanks to George for the idea of something less intrusive which I have now implemented.

What I have now is a text box that changes from 'Ready' to 'Call logged' (Background colour changes to green to highlight call logged' after a couple of seconds it changes back to normal with 'Ready'. This means that people do not have to see a message box coming up.

Thanks for all the comments and advice to everyone.

Cheers

Simon
 
As George says, message boxes should be reserved for situations when a user is required to acknowledge the information in them. This is part of the Microsoft UI specification.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top