|
-
March 15th, 2010, 04:50 PM
#1
Timer function problems
So i'm trying to disable a timer from counting down to 0 when a label is clicked but i keep running into problems. How could i accomplish this without any errors?
heres the current code bit.
Code:
Private Sub Label4_Click()
frm_1.Visible = False
Win.Visible = True
Win.lbl_amount.Caption = "Congratulations! $100"
Win.Shape1.Visible = True
Win.Label1.ForeColor = vbRed
Timer1.Item.Enabled = False
End Sub
I've tried changing it to Timer1.Enabled = False without any luck.
I'm very new to visual basic so help would be tremendously appreciated, Thanks.
-
March 15th, 2010, 04:51 PM
#2
Re: Timer function problems
The error shown is
Code:
Compile Error: Argument not Optional
-
March 15th, 2010, 07:03 PM
#3
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
-
March 15th, 2010, 09:22 PM
#4
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
-
March 16th, 2010, 01:55 AM
#5
Re: Timer function problems
 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?
-
March 16th, 2010, 02:00 AM
#6
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
-
March 16th, 2010, 08:51 AM
#7
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.
Last edited by WoF; March 16th, 2010 at 01:51 PM.
-
March 18th, 2010, 01:33 AM
#8
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|