Results 1 to 10 of 10

Thread: 30 minute timer

Hybrid View

  1. #1

    Thread Starter
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i want to have something happen every 30 minutes, like open iexplore. how do i do that
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Create a timer and set the interval to 60000. Now add this code to the general declarations section of your form:
    Code:
    Dim Minutes As Integer 'the number of minutes since the last 30 mins
    And add this code to the Timer Event of the time
    Code:
    'add one to the counter
    Minutes = Minutes + 1
    'check if 30 is reached
    If Minutes > 29 Then
        'reset the counter
        Minutes = 0
        Msgbox "30 minutes are elapsed"
    End If
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    You could also use the GetTickCount API...
    A bit more accurate

    Code:
    'Put in a module
    Option Explicit
    
    Private Declare Function GetTickCount& Lib "kernel32" ()
    
    Public Sub Timed_Event(ByVal Interval As Long)
        'Interval in minutes
        Dim Start As Long
        'Set Start of timer
        Start = GetTickCount                                    
        'Check for to see if interval elapsed, else loop
        
            Do While GetTickCount < Start + (Interval * 60000)          
            'allow other processes
    
                DoEvents                                                
            Loop
            'Your code goes here
    
    End Sub
    [Edited by dsy5 on 11-04-2000 at 05:49 PM]
    Donald Sy - VB (ab)user

  4. #4
    Guest
    No API/Timer needed.

    Code:
    Private Sub Command1_Click()
    
        Time = "00:00:00"
        Do
        Time2 = Format(Time, "hh:nn:ss")
        If Time2 = "00:30:00" Then MsgBox "Times up!": Exit Do
        DoEvents
        Loop
        
    End Sub
    [Edited by Matthew Gates on 11-05-2000 at 03:36 AM]

  5. #5
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by Matthew Gates
    Code:
        If Time2 = "00:29:00" Then MsgBox "Times up!":
    I think you need to change 29 to 30.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  6. #6
    Guest
    Oops. The little things...
    it was this line that I was looking at while writing the code:

    If Minutes > 29 Then

    So I was thinking 29. Don't know why.
    Hope BuggyProgrammer get's the point anyway.
    Nothing the little edit/delete image can't handle to fix the problem though .

  7. #7
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    http://forums.vb-world.net/showthrea...threadid=20868


    The dll raises events, so you don't have to use loops.
    If you want it, give me a shout.



    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  8. #8
    Guest
    Use the Timer function. It's similar to GetTickCount except it goes in intervals of 1000 ms rather than 1.
    Code:
    Sub NewTimer(ByVal Interval As Long)
        Do
            Start = Timer
        
            Do While Timer < Start + Interval
                DoEvents
            Loop
        Loop
    End Sub
    Usage:
    Code:
    'Start Timer in intervals of 30 min
    NewTimer 1800

  9. #9
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    or better, use SetTimer / KillTimer APIs
    it calls the function u specify (one of the params is the adress of the func - use AddressOf) when the time interval has passed, and u dont have to have any loops - ppl can still use the app.
    buzzwords are the language of fools

  10. #10

    Thread Starter
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    thanyou
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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