需要很长的间隔 [英] Require long interval

查看:64
本文介绍了需要很长的间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Reminder功能,我正在构建一个VB 6.0程序,它将会启动用户执行某些操作。我有一个滑块

,这个人可以选择从1

分钟到60分钟的提醒。


我想使用一个定时器,但发现它允许64K毫秒(刚刚超过

a分钟)作为最大间隔。我是否必须提出一个

复杂的数学例程才能处理为现在添加X分钟数。

我从未使用过MOD函数 - 会不会帮助我吗?


我正在考虑使用一分钟计时器和以下列车的

逻辑:


m =分钟(现在)

r =提醒频率(以分钟为单位)

n = m + r

每分钟增量m乘以1

如果m = n然后弹出提醒通知


在我看来,这不是完成任务最漂亮的方式,但是我

不必担心分钟值滚动(59滚动到

00)。是否存在更符合逻辑的例程?要做到这一点吗?


BTW,我正在使用24小时制(不是上午/下午)。


Tom

解决方案



" Kiteman(Canada)" < NO ************ @ shaw.ca>在消息中写道

新闻:Fhyvb.454214


9l5.180694@pd7tw2no ...

我有一个提醒功能,我我将构建一个VB 6.0程序
,它将(启用时)提醒用户执行某些操作。我有一个
的滑块,用户可以选择提醒,从
1分钟到60分钟。

我想使用Timer但是发现它允许64K毫秒
(仅一分多钟)作为最大间隔。我是否需要使用复杂的数学例程来提高
,以便将$ X分钟添加到
现在。我从来没有使用MOD功能 - 这对我有帮助吗?

我正在考虑使用一分钟计时器和以下逻辑列表:

m =分钟(现在)
r =提醒频率(以分钟为单位)
n = m + r
每分钟增量m乘以1
如果m = n则弹出提醒通知

在我看来,这不是完成任务最漂亮的方法,但是
我不必担心分钟值滚动(59滚动
到00) 。是否存在更符合逻辑的例程?要做到这一点?

顺便说一下,我正在使用24小时制(不是上午/下午)。

Tom




我认为这会奏效。但是,由于定时器只能在至少间隔时间后才能保证点火,但如果Windows

忙于其他东西,可能会迟到,经典等等。处理这类任务的方法

会更像这样:


''模块级变量

Dim dtAlarmTime as设置闹钟的过程中的日期


'':

dtAlarmTime = DateAdd(" n",60,Now())


''在计时器事件中:

如果Now()> dtAlarmTime然后

Msgbox提醒

''设置下一个间隔,如果需要

dtAlarmTime = DateAdd(" n",60,现在())

结束如果


这种方法消除了延迟计时器事件等的漂移。你可以

然后设置计时器间隔到任何数量,取决于你想要到达正确时间的接近程度。


汤姆说:

我有一个提醒功能,我正在构建一个VB 6.0程序,
将(启用时)提醒用户执行某些操作。我有一个
的滑块,用户可以选择提醒,从
1分钟到60分钟。



史蒂夫说:那会有效,我认为。但是,由于定时器只能在至少间隔时间后才能保证点火,但如果Windows
忙于其他事情,可能会延迟,经典等等。处理这类任务的方式更像是:

''模块级变量
Dim dtAlarmTime as Date

''in设置闹钟的过程:
dtAlarmTime = DateAdd(" n",60,Now())
''在计时器事件中:
如果Now()> ; dtAlarmTime然后
Msgbox提醒
''设置下一个间隔,如果需要
dtAlarmTime = DateAdd(" n",60,Now())
结束如果


非常感谢Steve的快速回复。我查看了DateAdd

函数,但是卡在了帮助文件中给出的示例中,该文件显示了一个

月添加了,我不知何故说服自己这不起作用对于

分钟:-)我有一个问题,即添加了提醒间隔

会将时间推到第二天并立即滚动到Now()时间

将大于dtAlarmtime。显然我也必须跟踪

的日期。


Tom


I have a Reminder feature that I am building into a VB 6.0 program that will
(when enabled) remind the user to perform some action. I have a slider
where the person can select for the reminder to come up anywhere from 1
minute to 60 minutes.

I wanted to use a Timer but found that it allows 64K milliseconds (just over
a minute) as the maximum interval. Am I going to have to come up with a
complicated math routine just to handle adding X number of minutes to Now.
I have never used the MOD function - would that help me out?

I was thinking of using a one minute timer with the following train of
logic:

m = Minutes(Now)
r = frequency of reminder (in minutes)
n = m + r
every minute increment m by 1
if m = n then popup reminder notice

In my mind, this is not the prettiest way to accomplish the task, but I
would not have to worry about the minute value rolling (59 rolling over to
00). Is there a routine that is "more logical" to do this?

BTW, I am using the 24hr clock (not am/pm).

Tom

解决方案


"Kiteman (Canada)" <NO************@shaw.ca> wrote in message
news:Fhyvb.454214


9l5.180694@pd7tw2no...

I have a Reminder feature that I am building into a VB 6.0 program that will (when enabled) remind the user to perform some action. I have a slider where the person can select for the reminder to come up anywhere from 1 minute to 60 minutes.

I wanted to use a Timer but found that it allows 64K milliseconds (just over a minute) as the maximum interval. Am I going to have to come up with a complicated math routine just to handle adding X number of minutes to Now. I have never used the MOD function - would that help me out?

I was thinking of using a one minute timer with the following train of
logic:

m = Minutes(Now)
r = frequency of reminder (in minutes)
n = m + r
every minute increment m by 1
if m = n then popup reminder notice

In my mind, this is not the prettiest way to accomplish the task, but I would not have to worry about the minute value rolling (59 rolling over to 00). Is there a routine that is "more logical" to do this?

BTW, I am using the 24hr clock (not am/pm).

Tom



That would work, I think. However, since timers are only guaranteed to
fire after at least the interval has elapsed, but may be late if Windows
is busy with other stuff, the "classic" way to handle this sort of task
would be more like this:

''a module level variable
Dim dtAlarmTime as Date

''in the procedure that sets the alarm:
dtAlarmTime = DateAdd("n",60, Now())

''in the timer event:
If Now() > dtAlarmTime Then
Msgbox "Reminder"
''set next interval, if desired
dtAlarmTime = DateAdd("n",60, Now())
End If

This approach eliminates drift from delayed timer events, etc. You can
then set the timer interval to any amount, depending on how close you
want to come to the correct time.


Tom said:

I have a Reminder feature that I am building into a VB 6.0 program that will (when enabled) remind the user to perform some action. I have a slider where the person can select for the reminder to come up anywhere from
1 minute to 60 minutes.


Steve said: That would work, I think. However, since timers are only guaranteed to
fire after at least the interval has elapsed, but may be late if Windows
is busy with other stuff, the "classic" way to handle this sort of task
would be more like this:

''a module level variable
Dim dtAlarmTime as Date

''in the procedure that sets the alarm:
dtAlarmTime = DateAdd("n",60, Now())

''in the timer event:
If Now() > dtAlarmTime Then
Msgbox "Reminder"
''set next interval, if desired
dtAlarmTime = DateAdd("n",60, Now())
End If

This approach eliminates drift from delayed timer events, etc. You can
then set the timer interval to any amount, depending on how close you
want to come to the correct time.



Thanks very much for this quick reply Steve. I had looked at the DateAdd
function, but got stuck on the example given in the help file which shows a
Month added and I somehow convinced myself that this would not work for
minutes :-) I had a concern with a Reminder interval being added that
would roll the time over to the next day and immediately the Now() time
would be greater than the dtAlarmtime. Obviously I have to keep track of
the date as well.

Tom


这篇关于需要很长的间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆