tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
I am trying to build my own countdown timer, using a userform counting down with a Wait function.
It doesn't work but what puzzles me most is it crashes.
This is in Moduel1:
This is in Userfrom1:
The code runs to the end of the Sub Timer, then goes back to the Sub Start and crashes on this line:
with the message:
What is wrong?
Thanks
It doesn't work but what puzzles me most is it crashes.
This is in Moduel1:
Rich (BB code):
Option Explicit
Sub Start()
UserForm1.Show
End Sub
Sub Timer()
Dim i As Integer
For i = 5 To 1 Step -1
UserForm1.Label1.Caption = i
Application.Wait (Now + TimeValue("0:00:01"))
Next i
Unload UserForm1
End Sub
This is in Userfrom1:
Rich (BB code):
Private Sub UserForm_Initialize()
Call Module1.Timer
End Sub
The code runs to the end of the Sub Timer, then goes back to the Sub Start and crashes on this line:
Rich (BB code):
UserForm1.Show
with the message:
Rich (BB code):
Object variable or With block variable not set
What is wrong?
Thanks