• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[VB6]Timer Won't Set to 120000

Newbie Spellweaver
Joined
Oct 16, 2008
Messages
85
Reaction score
0
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 ^^
 
Custom Title Activated
Loyal Member
Joined
May 25, 2007
Messages
1,025
Reaction score
31
You're supposed to set the interval via the Timer's Properties window.
 
Newbie Spellweaver
Joined
May 3, 2008
Messages
83
Reaction score
0
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.
 
Supreme Arcanarch
Loyal Member
Joined
Mar 23, 2007
Messages
931
Reaction score
10
Rename your timer to "timerlol" or something.
 
Newbie Spellweaver
Joined
Oct 16, 2008
Messages
85
Reaction score
0
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.

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).
 
hello
Loyal Member
Joined
Jun 24, 2004
Messages
726
Reaction score
158
Copy paste the error you got, exact. As we do not know what to search for.
 
Newbie Spellweaver
Joined
Oct 16, 2008
Messages
85
Reaction score
0
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 ...

Run Time Error '308':

Invalid Property Value
 
Newbie Spellweaver
Joined
May 3, 2008
Messages
83
Reaction score
0
>.> 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*
 
Newbie Spellweaver
Joined
Nov 20, 2008
Messages
11
Reaction score
0
>.> 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
 
Banned
Banned
Joined
Jun 24, 2008
Messages
723
Reaction score
1
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 = [b]"[/b]120000[b]"[/b]
 
hello
Loyal Member
Joined
Jun 24, 2004
Messages
726
Reaction score
158
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
MSDN Online said:
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
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.
 
Newbie Spellweaver
Joined
Oct 16, 2008
Messages
85
Reaction score
0
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.
 
Back
Top