an easy one

simple timer is killing me
I have a form with
hourtxt.text set to 1 (textbox)
mintxt.text set to 2 (textbox)
sectxt.text set to 59 (textbox)
mmsectxt.text set to 10 (textbox)
timer named CountdownTim set to 100
label1 set to show the timer counting down
and a command button set to enable the timer

here is the code
Dim miHra As Integer 'use for the Hours of the timer
Dim miMina As Integer 'use for the Minutes of the timer
Dim miSeca As Integer 'use for the Seconds of the timer
Dim mimmseca As Integer 'used for milliseconds for timer
Private Sub Command1_Click()
 CountdownTim.Enabled = True
End Sub

Private Sub CountdownTim_Timer() 'COUNTDOWN TIMER

miHra = hourtxt.Text 'hours
miMina = Mintxt.Text 'minutes
miSeca = Sectxt.Text 'seconds
mimmseca = mmSectxt.Text 'milliseconds

mimmseca = mimmseca - 1
If mimmseca = 0 Then
mimmseca = 10
miSeca = miSeca - 1

  End If
If miSeca = 0 Then
   miSeca = 60
   miMina = miMina - 1
End If
 
If miMina = 0 Then
   miMina = 60
   miHra = miHra - 1
End If
 
If miHra = 0 Then
   miHra = 12
End If
  Label1.Caption = miHra & ":" & miMina & ":" & miSeca & ":" & mimmseca
End Sub


now when I click on the command buttom, the label shows 1:2:59:10
and it doesn't move
It should at least show 1:2:59:9

why ain't it workin?
LVL 41
stevenlewisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

stevenlewisAuthor Commented:
my error, the label shows 1:2:59:9, but doesn't move
0
ampapaCommented:
Are you refreshing your label?
0
anaadoulCommented:
try this code instead of yours and tell me


Dim miHra As Integer 'use for the Hours of the timer
Dim miMina As Integer 'use for the Minutes of the timer
Dim miSeca As Integer 'use for the Seconds of the timer
Dim mimmseca As Integer 'used for milliseconds for timer
Private Sub Command1_Click()
 CountdownTim.Enabled = True
 miHra = hourtxt.Text 'hours
miMina = Mintxt.Text 'minutes
miSeca = Sectxt.Text 'seconds
mimmseca = mmSectxt.Text 'milliseconds

End Sub

Private Sub CountdownTim_Timer() 'COUNTDOWN TIMER

mimmseca = mimmseca - 1
If mimmseca = 0 Then
mimmseca = 10
miSeca = miSeca - 1

  End If
If miSeca = 0 Then
   miSeca = 60
   miMina = miMina - 1
End If
 
If miMina = 0 Then
   miMina = 60
   miHra = miHra - 1
End If
 
If miHra = 0 Then
   miHra = 12
End If
  Label1.Caption = miHra & ":" & miMina & ":" & miSeca & ":" & mimmseca
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anaadoulCommented:
This code is even better



Dim miHra As Integer 'use for the Hours of the timer
Dim miMina As Integer 'use for the Minutes of the timer
Dim miSeca As Integer 'use for the Seconds of the timer
Dim mimmseca As Integer 'used for milliseconds for timer
Private Sub Command1_Click()
 CountdownTim.Enabled = True
 miHra = hourtxt.Text 'hours
miMina = Mintxt.Text 'minutes
miSeca = Sectxt.Text 'seconds
mimmseca = mmSectxt.Text 'milliseconds

End Sub

Private Sub CountdownTim_Timer() 'COUNTDOWN TIMER

If Not mimmseca = 0 Then mimmseca = mimmseca - 1
If mimmseca = 0 And mimmseca > 0 Then
    mimmseca = 9
    If Not miSeca = 0 Then miSeca = miSeca - 1
    End If
If miSeca = 0 And miMina > 0 Then
   miSeca = 59
   If Not miMina = 0 Then miMina = miMina - 1
End If
 
If miMina = 0 And miHra > 0 Then
   miMina = 59
   If Not miHra = 0 Then miHra = miHra - 1
End If
 
'If miHra = 0 Then
'   miHra = 12
'End If
  Label1.Caption = miHra & ":" & miMina & ":" & miSeca & ":" & mimmseca
End Sub



----------------------------------
There Are 10 Kind OF People
Those Who Understands Binaray And Those Who Dont
0
stevenlewisAuthor Commented:
this code is even better stops after counting down 10 msecs
however the first code you posted works great.
You mean all I had to do was move
miHra = hourtxt.Text 'hours
miMina = Mintxt.Text 'minutes
miSeca = Sectxt.Text 'seconds
mimmseca = mmSectxt.Text 'milliseconds
from out of thetimer sub and to the click sub
Doh! LOL
thanks!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.