How do you multiple a variable called TimerInter by 60000?
I am trying to use it like this:
Timer1.Interval = TimerInter * 60000
Printable View
How do you multiple a variable called TimerInter by 60000?
I am trying to use it like this:
Timer1.Interval = TimerInter * 60000
Interval can't take such big values
Code:The interval can be between 0 and 64,767, inclusive, which means that even the longest interval can't be much longer than one minute (about 64.8 seconds).
That's correct, if the variable is declared as numeric value (Long, Double etc.) ...
Quintonir
this is the code I am using:
If Check1.Value = 1 Then
Timer1.Enabled = True
Timer1.Interval = Val(Text15.Text) * 60000
Else
Timer1.Enabled = False
End If
I tried dimming it as Long, and I am still getting an overflow error.
Sharp one, Vlatko, you got me there; I didn't know. Thanks.
Quintonir
As Vlatko stated earlier, the Interval property is not allowed to contain values passing a certain limit (64.767). Multiplying the TextBox with 60000 probably passes the limit.
Quintonir
As a work-around, use the Timer function.
Code:Dim bTime As Boolean
'Interval = Interval (in seconds)
Sub NewTimer(ByVal Interval As Long)
Do While bTime = True
Start = Timer
Do While Timer < Start + Interval * 60
DoEvents
Loop
<--Your code here-->
Loop
End Sub
Private Sub Command1_Click()
bTime = True
NewTimer 5
End Sub
Another work around is, to have a static variable in the timer event and if for example, you want it to go off every 5 minutes, set the interval for 60 000 and then use this:
static num as integer
if static < 5 then
static = static + 1
else
static = 0
'put code here
endif
This is real dodgy but you could also have multiple timers...
Timer1.Interval=64,767
Timer1 runs timer 2
Timer2.Interval=64,767
Timer2 runs timer 3
Timer3.Interval=64,767
Timer3 runs something
added together makes 3 minutes 13 seconds
GetTickCount is probably the best if you need high accuracy (excluding QueryPerformanceCounter). It can be as percise as 1 millisecond, or up to 49 days.
How about the SetTimer and the KillTimer?
Code:Public Declare Function SetTimer Lib "user32" _
Alias "SetTimer" (ByVal hWnd As Long, ByVal nIDEvent _
As Long, ByVal uElapse As Long, ByVal lpTimerFunc As _
Long) As Long
Public Declare Function KillTimer Lib "user32" _
Alias "KillTimer" (ByVal hwnd As Long, ByVal nIDEvent _
As Long) As Long
Public Function TimerSub(hwnd as long, msg as long, uid as long, systime as long) as long
if id=3 then
'Do
elseif id = ...
end sub
End Sub
'USE--------------
SetTimer (me.hwnd, 3, 488217443, addressof timersub)
'STOP------------
KillTimer(me.hwnd, 3)