Home All Groups Group Topic Archive Search About

i need timer interval more than 1 Minute.

Author
12 Apr 2006 6:38 PM
Tark Siala
hi
i am using timer control, its good but if my event doing less than one time
in 1 Minute.
i want make event every 5 minute, how i can do that?

i am using VB6, VB.NET

--
Best Regards

Tark M. Siala
Development Manager
INTERNATIONAL COMPUTER CENTER (ICC.Networking)
Mobile:          +218-91-3125900
E-Mail:          tarksi***@icc-libya.com
Messenger:    tarksi***@hotmail.com
Web Page:     http://www.icc-libya.com
Blog: http://spaces.msn.com/tarksiala
======================================

Author
12 Apr 2006 6:47 PM
Jason
in VB.net (not sure about 6...)

a timer with the interval of 1000 = 1000ms which = 1 s

so for 1 minute    60 * 1000 = 60,000

so for 5 minutes   60 * 5000 = 300,000



Show quoteHide quote
"Tark Siala" <tarksi***@icc-libya.com> wrote in message
news:eQbhNBmXGHA.508@TK2MSFTNGP02.phx.gbl...
> hi
> i am using timer control, its good but if my event doing less than one
> time in 1 Minute.
> i want make event every 5 minute, how i can do that?
>
> i am using VB6, VB.NET
>
> --
> Best Regards
>
> Tark M. Siala
> Development Manager
> INTERNATIONAL COMPUTER CENTER (ICC.Networking)
> Mobile:          +218-91-3125900
> E-Mail:          tarksi***@icc-libya.com
> Messenger:    tarksi***@hotmail.com
> Web Page:     http://www.icc-libya.com
> Blog: http://spaces.msn.com/tarksiala
> ======================================
>
Author
12 Apr 2006 6:55 PM
Bob Butler
"Jason" <ja***@genzlinger.com> wrote in message
news:%23vD70GmXGHA.4120@TK2MSFTNGP03.phx.gbl
> in VB.net (not sure about 6...)
>
> a timer with the interval of 1000 = 1000ms which = 1 s
>
> so for 1 minute    60 * 1000 = 60,000
>
> so for 5 minutes   60 * 5000 = 300,000

In VB6 the timer control is limited to 65535 so the usual method there is to
save the time ina module-level or static procedure level variable, set the
timer to 60000 (or any value >0 and <65536) and then when the timer event
fires compare "Now" to the saved time to determine if you have reached the
desired interval.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
12 Apr 2006 6:49 PM
Sankalp
You can assign the interval of your timer on form load to some value.
e.g. if your timer is Timer1, then
on form load :-
Timer1.Enabled = True
Timer1.Interval = 300000 ( 5 minutes)

This will fire the Timer1_Elapsed event where you can do your
processing.

-S
Author
12 Apr 2006 8:04 PM
Karl E. Peterson
Sankalp wrote:
> You can assign the interval of your timer on form load to some value.
> e.g. if your timer is Timer1, then
> on form load :-
>  Timer1.Enabled = True
>  Timer1.Interval = 300000 ( 5 minutes)

Not in ClassicVB, you can't!
--
Working without a .NET?
http://classicvb.org/
Author
12 Apr 2006 8:07 PM
Jason
perhaps its time for an upgrade?  ;)


Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:O%23qGkxmXGHA.4324@TK2MSFTNGP03.phx.gbl...
> Sankalp wrote:
>> You can assign the interval of your timer on form load to some value.
>> e.g. if your timer is Timer1, then
>> on form load :-
>>  Timer1.Enabled = True
>>  Timer1.Interval = 300000 ( 5 minutes)
>
> Not in ClassicVB, you can't!
> --
> Working without a .NET?
> http://classicvb.org/
>
>
Author
12 Apr 2006 8:12 PM
Karl E. Peterson
Jason wrote:
> perhaps its time for an upgrade?  ;)

Ah yes, if only there were...  (Signed the petition, yet? ;-)
--
Working without a .NET?
http://classicvb.org/
Author
12 Apr 2006 8:14 PM
Ken Halter
"Jason" <FB***@j.com> wrote in message
news:%23yI1izmXGHA.1476@TK2MSFTNGP03.phx.gbl...
> perhaps its time for an upgrade?  ;)
>

Nah... you'll find out the first time that 5 minutes is up and the OS has
swallowed a timer event <g>

Personally, I set the tick to about once per second (depending on a few
things) and use DateDiff to figure out if a certain amount of time has
elapsed. Timer events are just to flakey to rely on. By doing the math
myself, I eliminate the OSs ability (for the most part) to ruin my timing.

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Author
24 Apr 2006 4:40 PM
Hapticz
wholly agreed that the timer is not that exact or relaible. if you set interval to 1 second  (1000 ms), then there are 60 intervals
to accumulate error and mishaps. over a few hours or days it adds up.

ken's use of datedif is so much more solid and relies on the system clock, often one that is synched with external servers nowadays.
and less affected by code interrupts.

short run programs (on the spot office stuff) may be suitable for less exact synched code, but with most stuff now related to
internet and multiple user/client/server interaction, i would recommend Ken's suggestion.

Show quoteHide quote
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message news:#P#l02mXGHA.4144@TK2MSFTNGP04.phx.gbl...
> "Jason" <FB***@j.com> wrote in message
> news:%23yI1izmXGHA.1476@TK2MSFTNGP03.phx.gbl...
> > perhaps its time for an upgrade?  ;)
> >
>
> Nah... you'll find out the first time that 5 minutes is up and the OS has
> swallowed a timer event <g>
>
> Personally, I set the tick to about once per second (depending on a few
> things) and use DateDiff to figure out if a certain amount of time has
> elapsed. Timer events are just to flakey to rely on. By doing the math
> myself, I eliminate the OSs ability (for the most part) to ruin my timing.
>
> --
> Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
> DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
>
>
Author
12 Apr 2006 8:11 PM
Saga
This is what happens when the query is crossposted to Classic and .NET
groups :-)

Regards
Saga


Show quoteHide quote
"Karl E. Peterson" <karlNON@SPAMMEmvps.org> wrote in message
news:O%23qGkxmXGHA.4324@TK2MSFTNGP03.phx.gbl...
> Sankalp wrote:
>> You can assign the interval of your timer on form load to some value.
>> e.g. if your timer is Timer1, then
>> on form load :-
>>  Timer1.Enabled = True
>>  Timer1.Interval = 300000 ( 5 minutes)
>
> Not in ClassicVB, you can't!
> --
> Working without a .NET?
> http://classicvb.org/
>
>
Author
12 Apr 2006 8:18 PM
Karl E. Peterson
Saga wrote:
> This is what happens when the query is crossposted to Classic and .NET
> groups :-)

Exactly.  Two languages, two answers.
--
Working without a .NET?
http://classicvb.org/
Author
12 Apr 2006 8:34 PM
PulsarSL
dim interval as long
dim ticked as long

long = 30000 'or your time, in seconds
ticked=0

Private Sub Timer1_Timer()
     ticked = ticked + 1
     if ticked = interval then call yourfunction
end sub
Author
12 Apr 2006 8:45 PM
Karl E. Peterson
Pulsa***@gmail.com wrote:
> dim interval as long
> dim ticked as long
>
> long = 30000 'or your time, in seconds
> ticked=0
>
> Private Sub Timer1_Timer()
>      ticked = ticked + 1
>      if ticked = interval then call yourfunction
> end sub

Yeah, that's one idea (though I'd use Static procedure vars, myself), but as
others have pointed out this method is vulnerable.  You are hearby
admonished to write, 1000 times, on the blackboard:

  "Windows is not a real-time operating system."
  "Windows is not a real-time operating system."
  "Windows is not a real-time operating system."
  "Windows is not a real-time operating system."
  "Windows is not a real-time operating system."
  "Windows is not a real-time operating system."

--
Working without a .NET?
http://classicvb.org/
Author
13 Apr 2006 3:28 PM
Saga
And no loops of any kind can be used! <eg>

Saga


Show quoteHide quote
"Karl E. Peterson" <karlNON@SPAMMEmvps.org> wrote in message
news:%23SigaInXGHA.4424@TK2MSFTNGP05.phx.gbl...
> Pulsa***@gmail.com wrote:
>> dim interval as long
>> dim ticked as long
>>
>> long = 30000 'or your time, in seconds
>> ticked=0
>>
>> Private Sub Timer1_Timer()
>>      ticked = ticked + 1
>>      if ticked = interval then call yourfunction
>> end sub
>
> Yeah, that's one idea (though I'd use Static procedure vars, myself),
> but as
> others have pointed out this method is vulnerable.  You are hearby
> admonished to write, 1000 times, on the blackboard:
>
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>
> --
> Working without a .NET?
> http://classicvb.org/
>
>
Author
14 Apr 2006 12:20 PM
Ross Ylitalo
How about something like:

Sub Main()

    Dim datStart As Date


    myTimer.Interval = 10000 ' every 10 seconds
    datStart = DateTime.Now()
    Private Sub myTimer_Timer()
             If  DateTime.Now().SubTract(datStart).Minutes > 1 Then
                datStart = DateTime.Now()
                RunFunction()
            End If
    End Sub

End Sub


Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:%23SigaInXGHA.4424@TK2MSFTNGP05.phx.gbl...
> Pulsa***@gmail.com wrote:
>> dim interval as long
>> dim ticked as long
>>
>> long = 30000 'or your time, in seconds
>> ticked=0
>>
>> Private Sub Timer1_Timer()
>>      ticked = ticked + 1
>>      if ticked = interval then call yourfunction
>> end sub
>
> Yeah, that's one idea (though I'd use Static procedure vars, myself), but
> as
> others have pointed out this method is vulnerable.  You are hearby
> admonished to write, 1000 times, on the blackboard:
>
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>  "Windows is not a real-time operating system."
>
> --
> Working without a .NET?
> http://classicvb.org/
>
>
Author
12 Apr 2006 11:56 PM
Rich M
I usually set the Interval to 60000 (1 minute) and use the Timer's Tag
property as a minute counter:

Private Sub Timer1_Timer()
    If Val(Timer1.Tag) < 4 Then
        ' Increment minute counter
        Timer1.Tag = Val(Timer1.Tag) + 1
    Else
        ' Do actual stuff every 5 minutes

        ' Reset minute counter
        Timer1.Tag = "0"
    End If
End Sub


Show quoteHide quote
"Tark Siala" <tarksi***@icc-libya.com> wrote in message
news:eQbhNBmXGHA.508@TK2MSFTNGP02.phx.gbl...
> hi
> i am using timer control, its good but if my event doing less than one
> time in 1 Minute.
> i want make event every 5 minute, how i can do that?
>
> i am using VB6, VB.NET
>
> --
> Best Regards
>
> Tark M. Siala
> Development Manager
> INTERNATIONAL COMPUTER CENTER (ICC.Networking)
> Mobile:          +218-91-3125900
> E-Mail:          tarksi***@icc-libya.com
> Messenger:    tarksi***@hotmail.com
> Web Page:     http://www.icc-libya.com
> Blog: http://spaces.msn.com/tarksiala
> ======================================
>
Author
13 Apr 2006 7:18 AM
Michael C
"Rich M" <rmabry-nospam@jaguartc.com> wrote in message
news:OZSx8yoXGHA.1348@TK2MSFTNGP05.phx.gbl...
>I usually set the Interval to 60000 (1 minute) and use the Timer's Tag
>property as a minute counter:

>        Timer1.Tag = Val(Timer1.Tag) + 1

Yuk!

Michael
Author
13 Apr 2006 1:45 PM
Rich M
LOL - it works

Show quoteHide quote
"Michael C" <nospam@nospam.com> wrote in message
news:eFQaLqsXGHA.4988@TK2MSFTNGP05.phx.gbl...
> "Rich M" <rmabry-nospam@jaguartc.com> wrote in message
> news:OZSx8yoXGHA.1348@TK2MSFTNGP05.phx.gbl...
>>I usually set the Interval to 60000 (1 minute) and use the Timer's Tag
>>property as a minute counter:
>
>>        Timer1.Tag = Val(Timer1.Tag) + 1
>
> Yuk!
>
> Michael
>
Author
13 Apr 2006 2:19 PM
Bob Butler
"Rich M" <rmabry-nospam@jaguartc.com> wrote in message
news:ekAv7BwXGHA.3704@TK2MSFTNGP03.phx.gbl
> LOL - it works
>
> "Michael C" <nospam@nospam.com> wrote in message
> news:eFQaLqsXGHA.4988@TK2MSFTNGP05.phx.gbl...
>> "Rich M" <rmabry-nospam@jaguartc.com> wrote in message
>> news:OZSx8yoXGHA.1348@TK2MSFTNGP05.phx.gbl...
>>> I usually set the Interval to 60000 (1 minute) and use the Timer's
>>> Tag property as a minute counter:
>>>        Timer1.Tag = Val(Timer1.Tag) + 1

Except that it really doesn't.  With the vagaries of the timer firing it
tends to drift further and further from the desired intervals.  Checking Now
against a target time keeps it more accurate over a longer time span if
that's important.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
13 Apr 2006 11:07 PM
Michael C
"Rich M" <rmabry-nospam@jaguartc.com> wrote in message
news:ekAv7BwXGHA.3704@TK2MSFTNGP03.phx.gbl...
> LOL - it works

It does work but the complexity of what happens underneath is quite large.
It will do something like this:
- Retreive the timer.tag as a string
- Val will convert that to double
- the 1 is a 16bit int and will be converted to a double
- add the 2 together as doubles
- convert the result back to a string
- put the result back into the timer tag

on the other hand incrementing a module level variable will simply do an
increment which will be a single cpu instruction (the above would be
literally hundreds). While I don't think it's worth concerning yourself
overly with this sort of thing it is worth taking into account and not
writing inefficient code just because it's the same amount of typing. Once a
project got large if this sort of thing was used throughout it could bloat
it considerably.

Michael
Author
13 Apr 2006 5:43 AM
Cor Ligthert [MVP]
Tark,

In VBNet in at least 3 (4) different methods. This dependend if you use it
for a Form, a windowsservice or a multithreading application. For Webforms
will in the Atlas part as well a clientside timer be included.

Beside that can you in windowforms VBNet as well stop the processing one
minute or longer and get mostly the same effect.

I hope this helps,

Cor
Author
13 Apr 2006 11:19 AM
J French
On Wed, 12 Apr 2006 20:38:30 +0200, "Tark Siala"
<tarksi***@icc-libya.com> wrote:

>hi
>i am using timer control, its good but if my event doing less than one time
>in 1 Minute.
>i want make event every 5 minute, how i can do that?

>i am using VB6, VB.NET

For VB  (not B#)  I would set the interval to about 1 sec or less

and set up module variable as :-

   TargetTime = DateAdd( "n", 5, Now )

In the Timer Tick just check for

    If Now >= TargetTime Then ...