Results 1 to 8 of 8

Thread: Settings the timer value to more than 10 minutes

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Angry

    I know many programing languages like c++ delphi and so on, but I just started visual basic a month ago and noticed that you can not set the timer value to 600000 (ten minutes). Is there a way to set it to 10 minutes?
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  2. #2
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    There is a basic workaround:

    Code:
    Private Sub Timer1_Timer()
    Static TenMinutesPassed As Boolean
    
    If Not(TenMinutesPassed) Then
         Timer1.Enabled = False
         Timer1.Enabled = true
    Else:
         'Code here fires after approx twenty minutes
         Timer1.Enabled = False
    End If
    End Sub
    For more than twenty minutes:

    Code:
    Private Sub Timer1_Timer()
    Static TimesReached As Integer
    TimesReached = TimesReached + 1
    If TimesReached <= 6 Then
         Timer1.Enabled = False
         Timer1.Enabled = True
    Else:
         'Code here fires after approx 1 hr
         Timer1.Enabled = False
    End If
    You could, once you get used to VB, make your own timer control, but for now the code above should do.

    Enough gay banter,

    good bye
    Courgettes.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Post

    I'd rather make my own timer one way or another. If any1 know a simple way to make a timer that can have an interval of over 10 minutes, then reply please. Thanks, your help is appreciated!!!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  4. #4
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    If you know VC++, you'll know about the API.

    The call you need to make is GetTickCount:
    Code:
    Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    And the important bit would go like this:

    Code:
    Dim EndTime As Long
    EndTime = GetTickCount + (Minutes * 60000)
    Do While EndTime > GetTickCount
        DoEvents
    Loop
    RaiseEvent Timer
    I hope this helps.

    PS If you don't know about the API, I'm sure one of us kind , generous , giving people will be willing to help .
    Courgettes.

  5. #5
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    The timers in VB can be set to a max of 65,535 milliseconds, or just over 65 seconds.

    I needed a way to allow the user to set the time intervals at any value, up to 15 minutes.

    So, create a timer. When you start the timer, save the current time in a variable. Set the timers interval to 60,000 so it will check the current time every minute. In the timer subroutine, just check the elapsed time that has passed.

    When the chosen amount of time has passed, reset the variable and that will start your count over again.

    I do not have any beautiful code to post, but if you need more information I will see if I can set something up.

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    Talking api baby

    api - you can rewrite windows with them (of course it will crash cus ms made the api functions)

    but back to the topic - use the api calls like VERY suggested

  7. #7
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736

    Talking

    I like V(ery) Basic's suggestion also. Looks a lot cleaner. Putting it into my code now.

    If all else fails, API it.

  8. #8
    Guest
    Try this. (No API needed)
    Code:
    Dim bTime As Boolean
    
    Sub TimerEx(lTime As Integer)
    
        Do While bTime = True
            Start = Timer
            
            Do While Timer < Start + lTime
                DoEvents
            Loop
            
            '<--Place your code here-->
            
        Loop
        
    End Sub
    
    Private Sub Command1_Click()
        'Start timer (for 10 minutes)
        bTime = True
        TimerEx 600
    End Sub
    
    Private Sub Command2_Click()
        'Stop timer
        bTime = False
    End Sub

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