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?
Printable View
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?
There is a basic workaround:
For more than twenty minutes: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
You could, once you get used to VB, make your own timer control, but for now the code above should do.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
Enough gay banter,
good bye
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!!!
If you know VC++, you'll know about the API.
The call you need to make is GetTickCount:
And the important bit would go like this:Code:Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
I hope this helps.Code:Dim EndTime As Long
EndTime = GetTickCount + (Minutes * 60000)
Do While EndTime > GetTickCount
DoEvents
Loop
RaiseEvent Timer
PS If you don't know about the API, I'm sure one of us kind :rolleyes: , generous :rolleyes: , giving :rolleyes: people will be willing to help :rolleyes: .
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.
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
I like V(ery) Basic's suggestion also. Looks a lot cleaner. Putting it into my code now.
If all else fails, API it.
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