time elapse on userform label caption

P

pswanie

im trying to instead of just showing "system busy. pls wait" to show "system
busy" "time left **sec's"


this i got from a posting here:

Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:05"), "KillTheForm"
End Sub


im trying to use this:

Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:30"), Label3.Caption.(30sec)

Application.OnTime Now + TimeValue("00:00:20"), Label3.Caption = "20sec"

Application.OnTime Now + TimeValue("00:00:10"), Label3.Caption = "10sec"

Application.OnTime Now + TimeValue("00:00:05"), Label3.Caption = "05sec"

Application.OnTime Now + TimeValue("00:00:05"), "KillTheForm"

End Sub
 
B

Bob Phillips

Add this code to a standard code module

Public nTime As Long

Public Sub UpdateLabel()

UserForm1.Label3.Caption = Format(nTime, "0 secs")
nTime = nTime - 1
If nTime >= 0 Then
Application.OnTime Now() + TimeSerial(0, 0, 1), "UpdateLabel"
Else
UserForm1.Label3.Caption = "Time up"
End If
End Sub


then in your form, activate it with

Private Sub UsrForm_Activate()
nTime = 30
Call UpdateLabel
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
P

pswanie

do i take my other time code out? or just add it to urs?

if i use ur code only i dont get any reaction on my userform. it does not
update label3 nor close the userform
 
B

Bob Phillips

Ditch your code.

I didn't add code to close the form, you will need to add that.

The code assumes that the form is called Userform1.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top