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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer - Click Button - wait 10 min - popup message 2

Status
Not open for further replies.

zenenigma

Programmer
Apr 23, 2001
119
US
Situation:

I would like to:

1) enter a word into a textbox
2) click a button
3) have the program wait 10 minutes (allowing me to do other things on the form (doevents, I assume))
4) have a message box pop up with the word in the text box after 10 minutes.

The timer control is irritating me, mostly because it can only handle 1 minute. I'd also like a label control to show me how many minutes are left before the 10 minutes are up (updated once per minute).

Any help would be greatly appreciated.
 
You could fire the timer 10 times and since you are keeping track if how many times you have fired it you could somehow send that to a label...
[infinity]

Sam
 
declare a global variable intMinute and with every passing minute increment the counter until intMinutes = 10.
 
The Timer control will do exactly what you're after:

In the Click event of your button:

Timer1.Interval = 60000
Timer1.Enabled = True

In the Timer1 event:

Static temp
If temp = 0 Then
MsgBox "It's time"
temp = 10
Else
temp = temp - 1
End If
Label1.Caption = temp & " mins to go"


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Johnwm I tried your code, however after 1 minute, it pops up with the message saying "10 minutes to go".

I thank you other guys for your help. I'm not really having a problem with the concept, I'm having a problem calling the timer function multiple times. Every way I try it I get a message after 1 minute and can't seem to restar the timer control again.

 
Option Explicit
Dim intMinute As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
intMinute = intMinute + 1
If intMinute = 10 Then
Timer1.Enabled = False
MsgBox "Time's Up"
End If
Label1.Caption = 10 - intMinute & " minutes left."
End Sub
 
Make sure the enabled property is set to false and interval to 60000, initially.
 
Change the value of temp to 9 and be patient - it will run through and do just what you asked. That's what the Static keyword does - it retains it's value between calls to the routine. You don't call the Timer function - it calls itself when you enable it. You may want to set Timer1.Enabled = False in the If section.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanks everyone for your help, everything is working fine now. Now I know, and knowing's half the battle.
 
There are times when I think I'll just give up and go home!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top