[VB6]Timer Won't Set to 120000
Stupid timers on my project refuse to accept the interval 120000 (2minutes in milliseconds).
I tried putting
Code:
Timer.Interval = 120000
And all I got is an error message. My teacher said that it takes code to fix but thats all I can think of.
I think I need to multiply the number of times the timer counts (like 5k milli seconds * 24 [so it equals 120k milliseconds...2 minutes])
Help a nub please ^^
Re: [VB6]Timer Won't Set to 120000
You're supposed to set the interval via the Timer's Properties window.
Re: [VB6]Timer Won't Set to 120000
Don't have to. IDK who your teacher is but... >.> Epic phael.. "Timer" can not be the name of a timer without messing up code. Rename it to timer1 or whatever you want, but because timer is initially referred to as a keyword, you'll have error. Other possible reason is it's too high for whatever vb uses to store integers, so you'll have to google creating longs in vb or something along those lines. Otherwise, there is absolutely nothing wrong with the code, idk what the hell your teacher is thinking about.
Re: [VB6]Timer Won't Set to 120000
Rename your timer to "timerlol" or something.
Re: [VB6]Timer Won't Set to 120000
Quote:
Originally Posted by
9000234
Don't have to. IDK who your teacher is but... >.> Epic phael.. "Timer" can not be the name of a timer without messing up code. Rename it to timer1 or whatever you want, but because timer is initially referred to as a keyword, you'll have error. Other possible reason is it's too high for whatever vb uses to store integers, so you'll have to google creating longs in vb or something along those lines. Otherwise, there is absolutely nothing wrong with the code, idk what the hell your teacher is thinking about.
I have used mostly all my command button names and such as Quit/Check/Guess/End and so it. It has never messed up my code. Please do not insult my teacher. As for your suggestion... I have no idea what to search for so that was absolutely no help at all. Thanks anyway.
Quote:
You're supposed to set the interval via the Timer's Properties window.
I tried that too. It refuses to set to 120,000 (no comma added of course).
Re: [VB6]Timer Won't Set to 120000
Copy paste the error you got, exact. As we do not know what to search for.
Re: [VB6]Timer Won't Set to 120000
Lol...when I try to enter the value 120000 in properties window for the timer.. it just shows a popup saying
Invalid Property Value
If I put
Code:
Timer.Interval = 120000
into my code then.. I get the ...
Quote:
Run Time Error '308':
Invalid Property Value
Re: [VB6]Timer Won't Set to 120000
>.> Well obviously you didn't read what I said. IT CAN'T BE CALLED TIMER WITHOUT HAVING ERRORS! Just name it timertest or timerlol or timer1 or tmr or whatever you wanna call it BESIDES TIMER! *spazzes out*
Re: [VB6]Timer Won't Set to 120000
Quote:
Originally Posted by
9000234
>.> Well obviously you didn't read what I said. IT CAN'T BE CALLED TIMER WITHOUT HAVING ERRORS! Just name it timertest or timerlol or timer1 or tmr or whatever you wanna call it BESIDES TIMER! *spazzes out*
The timer can have any names <.<
The timer interval can't go over 65535... so you will have to use more timers or make a code that counts to 2min.
Here is some help:
Make a Timer named: Timer1
And then a Label named: Label1
Then use this codes:
Code:
Dim xtimer
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
xtimer = xtimer + Val(1)
Label1.Caption = "Time: " & xtimer & " sec."
If xtimer = 120 Then
MsgBox "2min!"
End
End If
End Sub
Re: [VB6]Timer Won't Set to 120000
Quote:
Originally Posted by
Hammad
You're supposed to set the interval via the Timer's Properties window.
You can do it like how he has put it in the code.
Try:
Code:
Timer1.Interval = "120000"
Re: [VB6]Timer Won't Set to 120000
Quote:
Originally Posted by
Eiian
The timer can have any names <.<
The timer interval can't go over 65535... so you will have to use more timers or make a code that counts to 2min.
Here is some help:
Make a Timer named: Timer1
And then a Label named: Label1
Then use this codes:
Code:
Dim xtimer
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
xtimer = xtimer + Val(1)
Label1.Caption = "Time: " & xtimer & " sec."
If xtimer = 120 Then
MsgBox "2min!"
End
End If
End Sub
Im must upset you but i looked into goodle and msdn documentation and your theory about cannot go pass 65635 is pretty much crap as the msdn says
Quote:
Originally Posted by MSDN Online
Property Value
Type: System.Int32
An Int32 specifying the number of milliseconds before the Tick event is raised relative to the last occurrence of the Tick event. The value cannot be less than one.
And further it says
Quote:
Remarks
The Int32 value type represents signed integers with values ranging from negative 2,147,483,648 through positive 2,147,483,647.
I'm correct unless you are not using System.Windows.Forms.Timer if you are using this one and you still cannot use 120,000 and your var is not named Timer ( wich actually should be no difference at all ). So forgive me but i don't have a single solution to your problem. The only idea to ommit this bug is trying to make a child class from Timer and make your own property Interval wich would be actually type int or Int16 or any other int and trying to ommit it,
Also if you could post all your code wich is relative to this i would be greatfull maybe there is problem with something else wich results in this Exception.
Re: [VB6]Timer Won't Set to 120000
I simply made a 4 timers each of 30k milliseconds.
This is how it worked
Code:
Private Sub Timer_Timer()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Timer2.Enabled = True
End Sub
Private Sub Timer2_Timer()
Timer3.Enabled = True
End Sub
Private Sub Timer3_Timer()
'put what you want to happened after two minutes here
End Sub
Thanks Eiian. And Everyone else.