[算表] Do While LOOP & Application.OnTime

楼主: ckingsu (ckingsu)   2025-01-23 13:16:50
软件: excel
版本: 2021
Sub atime123()
Range("Aa21") = 0
time0 = Time()
time1 = Time()
Do While Range("Aa21") <> Range("Ab21")
time1 = Time() + TimeSerial(0, 0, 1)
Range("Aa21") = DateDiff("s", time0, time1)
DoEvents
Loop
End Sub
虽有 DoEvents 再执行Application.OnTime程序 还是没办法正确执行 ??
作者: newacc (XD)   2025-01-23 17:26:00
你认为怎样是正确执行?OnTime写在哪里?https://i.imgur.com/O7kMNmq.mp4https://i.imgur.com/5HkP3EL.png
楼主: ckingsu (ckingsu)   2025-01-23 20:39:00
Range("Aa21") = DateDiff("s", time0, time1)改用debug.pring, 或用变量取代application.ontime 就能正确执行不知为何会如此?我需要储存格动态秒数,不知怎么改?在不影响其他程序的情况下
作者: newacc (XD)   2025-01-24 02:56:00
我提供的萤幕录影就是你说的储存格动态秒数吧?是由你文章里的程式码改的,没办法执行的话,需要更详细的程式码才有办法判断了你的OnTime是写在哪里?呼叫什么?
楼主: ckingsu (ckingsu)   2025-01-24 05:48:00
my = #12:00:10 AM#The_Time = Now + myApplication.OnTime The_Time, "timestock"Range("J16").Value = Format(The_Time, "hh:mm:ss")10秒执行一次timestocktimestock->写一些DDE的资料到储存格(程式码不短就不引出on time 在第二个10秒就不动了 ?改 A=DateDiff("s", time0, time1)就会动了我刚又随便写一个简单的on time 测试也是不行sub acde123()[a1] = [a1] + 1sw = #12:00:02 AM#aaa = Now + swApplication.OnTime aaa, "acde123"end sub

Links booklink

Contact Us: admin [ a t ] ucptt.com