请高手支招.急求!如何使timer事件的循环的时间为三分钟?
解决方案 »
- 请教:VB 中OPEN语句都能打开什么文件?
- 关于api函数CreateProcessWithLogonW
- Socket发送数据问题
- 学习VB要看哪些书?学习vb.net要看哪些书?
- 怎么循环读取DAT中的数据放入一维数组
- 如何实现类似窗体吸合的功能
- 使用RegEnumKeyEx,总是返回87(ERROR_INVALID_PARAMETER)错误。
- 怎么样才能在AutoCAD窗口为隐藏时调用缩放功能?
- 有关汉诺塔的程序
- DataGrid控件可否可以和DATA控件或DAO连接。
- Private WithEvents MyVSFlexGrid As VBControlExtender
- 这个dll中的函数在vb中能调用吗?
Private Sub tmr_Timer()
if i=2 then
'-- Do your things
i=0
end if
i=i+1
End Sub
Dim lTimerId As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As LongPrivate Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As LongPrivate Sub TimerProc(ByVal lHwnd As Long, ByVal lMsg As Long, ByVal lTimerId As Long, ByVal lTime As Long)Dim lResult As Long
lResult = StopTimer(lTimerId)
Call InsertYourProcessNameHere
'code to be executed after interval
End SubPublic Sub StartTimer(lInterval As Long) 'convert interval to milliseconds prior to passing
lTimerId = SetTimer(0, 0, lInterval, AddressOf TimerProc)
End SubPublic Function StopTimer(lTimerId As Long) As Long
'must pass the TimerId returned by SetTimer
StopTimer = KillTimer(0, lTimerId)
End Function'调用方式
Call StartTimer(3*60*1000) '3 minutes
Dim dtNextTime as DatePrivate Sub Form_load()
Timer1.interval=500
Timer1.Enabled=True
dtNextTime=DateAdd("n",3,Now)'3分钟执行一次任务
End SubPrivate Sub Timer1_Timer()
if Now>=dtNextTime Then
Timer1.Enabled=False
'在此加入你的代码 dtNextTime=DateAdd("n",3,Now)
Timer1.Enabled=True
End if
End Sub
dim T as long
sub form_load()
timer.interval=10000 '计时器10秒钟出发一次
end subPrivate Sub Timer1_Timer()
T=T+1
if T=18 then '触发满18次就是三分钟
'这里写你3分钟执行一次的代码
T=0 '从头来过
end if
End Sub简单不,再长的时间也这么解决
static i as long
i=i+1
if i>180 then
i=0
end if 每一秒i+1等i>180时就是3分钟了三.