Re: Timer function problems
The error shown is
Code:
Compile Error: Argument not Optional
Re: Timer function problems
You didn't show your Timer() code, which you need. Here's a sample:
Code:
Option Explicit
' Add a Timer control to your project. It will be Timer1
' It looks like a stop watch in the IDE.
Dim OldTime As Date
Dim newTime As Date
Dim diff As Long
Private Sub Form_Load()
OldTime = DateAdd("s", 360, Time) ' Add 360 seconds
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
newTime = Time
diff = DateDiff("s", newTime, OldTime)
Form1.Caption = (diff \ 3600) & ":" & Format((diff \ 60 Mod 60), "00") & ":" & _
Format((diff - ((diff \ 60) * 60)), "00")
If diff = 0 Then
Timer1.Enabled = False
' You time is UP! Do something!
Beep
End If
End Sub
Re: Timer function problems
Leave out the "Item" bit
The Correct code is Timer1.enabled=False
not Timer1.Item.Enabled=false
I think this solves your problem
Re: Timer function problems
Quote:
Originally Posted by
TurboBob
Leave out the "Item" bit
The Correct code is Timer1.enabled=False
not Timer1.Item.Enabled=false
I think this solves your problem
no i tried Timer1.Enable = false
also to the comment above this one i'm quoting, i don't quite understand.. maybe if i posted my program through a zip someone could get a better understanding of what i'm trying to do?
Re: Timer function problems
http://www.megaupload.com/?d=IGGJVBWI
Heres the zipped program, it includes all the forms along with the project.vbp
on frm_1 try placing timer1.enabled = false under label4_click
it just doesn't run through for me :(
Re: Timer function problems
Ok, I can tell you why Timer1.Enabled = False does not work.
For some reason you have set the Index property of your timers to zero. That makes them part of a control array, what you don't want.
Just examine all your timers' properties and erase the index property. Not just setting the value to zero, but deleting the value, leaving the field empty.
After That Timer1.Enabled = False will work.
If you reconsider your programming concept: Why do you want to make 15 individual question forms, when they are all identical. If you think about, you will find that you need only ONE form like your frm_1 with the question and the 4 answer labels. You can fill in the question data and title text before you show the form and thus only ever need one form of this kind.
Re: Timer function problems
Also if your timer is part of a control array [e.g. has an index value] you simply use the index value as part of the statement
Code:
timer1(0).enabled=false
Of course if you only have one timer there is no reason to have an index value on it.