Results 1 to 11 of 11

Thread: Dumb Question...

  1. #1

    Thread Starter
    Junior Member ComputerWiz6996's Avatar
    Join Date
    Dec 2000
    Location
    Tampa, FL
    Posts
    31

    Talking

    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

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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).
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155
    That's correct, if the variable is declared as numeric value (Long, Double etc.) ...


    Quintonir

  4. #4

    Thread Starter
    Junior Member ComputerWiz6996's Avatar
    Join Date
    Dec 2000
    Location
    Tampa, FL
    Posts
    31

    Arrow 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

  5. #5
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155
    Sharp one, Vlatko, you got me there; I didn't know. Thanks.


    Quintonir

  6. #6
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155
    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

  7. #7
    Guest
    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

  8. #8
    Guest
    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

  9. #9
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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

  10. #10
    Guest
    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.

  11. #11
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    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
  •  



Click Here to Expand Forum to Full Width