ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Application.OnTime µLªk²×¤î ?

[µo°Ý] Application.OnTime µLªk²×¤î ?

Sub amou()
Range("a1") = Range("a1") + 1
runtime2 = Now + TimeValue("00:00:10")
Application.OnTime runtime2, "amou"
End Sub

Sub a123()
On Error Resume Next
'Application.OnTime EarliestTime:=TimeValue(Runtime2), _
'   Procedure:="amou", Schedule:=False
' Application.OnTime EarliestTime:=Runtime2, _
  '   Procedure:="amou", Schedule:=False
  Application.OnTime runtime2, "amou", Schedule:=False
On Error GoTo 0
End Sub

¦^´_  t8899
­×§ï:
GBKEE µoªí©ó 2015-3-29 15:05


§Ú­è¤S¸Õ¥X¥t¤@ºØ°±¤î¤èªk
§â¥þ³¡ªº time §ï¬° now ´N¥i¥H¤F! (¤£ª¾¬°¤°»ò??)

TOP

¦^´_ 24# t8899
­×§ï:
  1. Sub Ex_Stop_OnTime()
  2.     If runtime2 < Time Then Exit Sub
  3.     Do
  4.         DoEvents
  5.     Loop Until runtime2 > Time
  6.     Application.OnTime runtime2, "EX_a123", , False
  7.      With Rng
  8.         .Value = ""
  9.         .Font.Size = 12
  10.         .Font.Bold = False
  11.         .Interior.ColorIndex = xlNo
  12.     End With
  13. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899
¸Õ¸Õ¬Ý
¤@¯ë¼Ò²Õªºµ{¦¡½X
GBKEE µoªí©ó 2015-3-29 14:17


Book3.zip (7.6 KB)

TOP

¦^´_ 22# t8899
¸Õ¸Õ¬Ý
¤@¯ë¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Dim runtime2 As Date, Rng As Range
  3. Sub AUTO_OPEN()
  4.     Ex_OnTime
  5. End Sub
  6. Sub Ex_OnTime()
  7.     Set Rng = Sheets("Sheet1").[a1]
  8.     EX_a123
  9. End Sub
  10. Sub Ex_Stop_OnTime()
  11.     Application.OnTime runtime2, "EX_a123", , False
  12.      With Rng
  13.         .Value = ""
  14.         .Font.Size = 12
  15.         .Font.Bold = False
  16.         .Interior.ColorIndex = xlNo
  17.     End With
  18. End Sub
  19. Sub EX_a123()
  20.     With Rng
  21.         .Value = .Value + 1
  22.         .Font.Size = IIf(.Font.Size = 12, 14, 12)
  23.         .Font.Bold = IIf(.Font.Size = 12, False, True)
  24.         .Interior.Color = IIf(.Font.Size = 12, vbYellow, vbRed)
  25.     End With
  26.     runtime2 = Time + #12:00:01 AM#
  27.     Application.OnTime runtime2, "EX_a123"
  28. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899
½Ð¦b§AVBA ±M®×¤¤´¡¤J¤@ªí³æ
ªí³æ¼Ò²Õµ{¦¡½X¤@¯ë¼Ò²Õµ{¦¡½X
GBKEE µoªí©ó 2015-3-29 11:40

©êºp¡A¤£¬O«ÜÀ´¡A¥i§_¤´¥H18¼Óªº¨Ò¤l¡A¦s¦¨ÀɮסAÅý¤p§Ì´ú¸Õ?

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-3-29 12:05 ½s¿è

¦^´_ 20# t8899
½Ð¦b§AVBA ±M®×¤¤´¡¤J¤@ªí³æ
ªí³æ¼Ò²Õµ{¦¡½X
  1. Option Explicit
  2. Private Sub UserForm_Activate()
  3.     Dim t As Date
  4.     Me.Hide
  5.     Ex_­n°õ¦æªºµ{¦¡
  6.     t = Time
  7.     Do
  8.         If Msg Then Exit Do
  9.         DoEvents
  10.         If Time > t + #12:00:01 AM# Then
  11.            If Not Msg Then Ex_­n°õ¦æªºµ{¦¡
  12.             t = Time
  13.         End If
  14.     Loop
  15. End Sub
  16. Private Sub userForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  17.     If Msg = False And Msg1 = False And CloseMode = 1 Then
  18.         Msg = True
  19.         Msg1 = True
  20.         MsgBox "µ{¦¡µ²§ô"
  21.     Else
  22.         MsgBox "µ{¦¡¤£¦b°õ¦æ¤¤"
  23.     End If
  24. End Sub
½Æ»s¥N½X
¤@¯ë¼Ò²Õµ{¦¡½X
  1. Option Explicit
  2. Public Msg As Boolean, Msg1 As Boolean
  3. Sub ex_Start()
  4.     Msg = False
  5.     UserForm1.Show (False)
  6. End Sub
  7. Sub Ex_End()
  8.     Unload UserForm1
  9. End Sub
  10. Sub Ex_­n°õ¦æªºµ{¦¡()
  11.     Msg1 = False
  12.     With ActiveSheet.[a1]
  13.         .Value = .Value + 1
  14.         .Font.Size = IIf(.Font.Size = 12, 14, 12)
  15.         .Font.Bold = IIf(.Font.Size = 12, False, True)
  16.     End With
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899
¦b³o  Sub amou() ªº¼Ò²Õ³»ºÝ«Å§i runtime2 ¬°¤½¥ÎÅܼÆ
¦p¦¹ Sub a123() ¤~¥i±o¨ìruntime2  ...
GBKEE µoªí©ó 2015-3-29 10:01

ÁÂÁÂ!´X¬í°õ¦æ¤@¦¸¦³µL¨ä¥L¤èªk??
¤×¨ä¹³1¬í1¦¸(®ÉÄÁ)¡A·Æ¹««ü¼Ð·|Åܦ¨º|¤æ¤@°{¤@°{ªºª¬ºA...

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-3-29 10:04 ½s¿è

¦^´_ 1# t8899
¦b³o  Sub amou() ªº¼Ò²Õ³»ºÝ«Å§i runtime2 ¬°¤½¥ÎÅܼÆ
¦p¦¹ Sub a123() ¤~¥i±o¨ìruntime2 ÅܼÆ
  1. Public runtime2 As Date
  2. Sub amou()
  3. 'Dim runtime2 As Date ¤£­n¦A«Å§i runtime2 ÅܼÆ
  4. Range("a1") = Range("a1") + 1
  5. runtime2 = Now + TimeValue("00:00:10")
  6. Application.OnTime runtime2, "amou"
  7. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

ÁÙ¬O°Ê¤£¤F
Cells(1 + a, 1) = Time ===>¬O¤°·N«ä
t8899 µoªí©ó 2013/1/22 23:56

¬d¬ÝVBAªº»¡©ú¥i¤F¸Ñ

TOP

        ÀR«ä¦Û¦b : ­ì½Ì§O¤H´N¬Oµ½«Ý¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD