|
-
Mar 31st, 2001, 03:32 PM
#1
Thread Starter
Junior Member
How do you multiple a variable called TimerInter by 60000?
I am trying to use it like this:
Timer1.Interval = TimerInter * 60000
Eric - ComputerWiz6996
Live long... Live well... Code Alot 
-
Mar 31st, 2001, 03:34 PM
#2
Frenzied Member
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).
-
Mar 31st, 2001, 03:35 PM
#3
Addicted Member
That's correct, if the variable is declared as numeric value (Long, Double etc.) ...
Quintonir
-
Mar 31st, 2001, 03:39 PM
#4
Thread Starter
Junior Member
The code
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.
Eric - ComputerWiz6996
Live long... Live well... Code Alot 
-
Mar 31st, 2001, 03:39 PM
#5
Addicted Member
Sharp one, Vlatko, you got me there; I didn't know. Thanks.
Quintonir
-
Mar 31st, 2001, 03:43 PM
#6
Addicted Member
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
-
Mar 31st, 2001, 05:07 PM
#7
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
-
Mar 31st, 2001, 05:21 PM
#8
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
-
Mar 31st, 2001, 05:26 PM
#9
PowerPoster
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
-
Mar 31st, 2001, 05:31 PM
#10
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.
-
Mar 31st, 2001, 10:17 PM
#11
Frenzied Member
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)
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
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
|