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

[¤À¨É] ¤À¨Éªº©w®É§ìDDE¸ê®Æµ{¦¡½X¡A¦ý¬O»Ý­n¤H«üÂI°g¬z

[¤À¨É] ¤À¨Éªº©w®É§ìDDE¸ê®Æµ{¦¡½X¡A¦ý¬O»Ý­n¤H«üÂI°g¬z

³o°}¤l¦£µÛ²Î­p¸ê®Æ¡A¤@¤è­±¤S¬[ºc¨t²Î¡A·PÁ¦¹°Q½×°Ï«Ü¦hª©¤jªº¨ó§U¡A²×©ó¦³¤@­Ó§¹¾ãªºª©¥»·Q¤À¨Éµ¹¤j®a

¤@¯ë¤£ºÞ¬Oª÷¿Ä·~¤H©Î¬O¤@¯ë§ë¸ê¤H ³£·|§Q¥Î¨é°ÓªºDDE ¥h§ì¸ê®Æ ¨Ã¥B°µ¤ÀªR©Î¦¡¾Þ§@

¦³¤@­ÓªB¤Íµ¹¤F§Ú¤@­Ó½d¨Ò  ¦p¤U  §Ú·Q¤À¨Éµ¹¤j®a¡A©çÁ¦]¬°§ìªºDDE¸ê®Æ¤£¦P ½Ð¦U¦ì¦Û¦æ½Õ¾ã  ¦ý¬O§Ú¦³¤@­Ó¦a¤è¬Û·íªº¤£À´  §Æ±æ½Ð«e½ú¥Î¥Õ¸Ü¤å¤ÀªR

¾ã­Óµ{¦¡½X¬O³o¼Ë¤l ³o­Óµ{¦¡½X¥i¥H¦Û¤v­×§ï§ì¸ê®Æªº®É¶¡  Ä@»P¤j®a¤À¨É¦@¦P°Q½×
  1. Option Explicit

  2. Dim T1 As Date

  3. Const ¶}©l = "08:45:05"
  4. Const µ²§ô = "13:46:08"
  5. Const ¶g´Á1 = "0:0:10"

  6. Sub start()

  7. Call StopTimer

  8. Call Timer1

  9. End Sub

  10. Sub StopTimer()

  11. On Error Resume Next

  12. Application.OnTime T1, "Timer1", , 0

  13. T1 = 0

  14. End Sub

  15. Sub Timer1()

  16. If T1 Then

  17. Sheets("¥x«ü").Range("B6000").End(xlUp).Offset(1, 0) = Sheets("sheet1").Range("B2")

  18. Sheets("¹q«ü").Range("B6000").End(xlUp).Offset(1, 0) = Sheets("sheet1").Range("B4")

  19. Sheets("ª÷«ü").Range("B6000").End(xlUp).Offset(1, 0) = Sheets("sheet1").Range("B6")

  20. End If

  21. T1 = TimeNext(¶}©l, µ²§ô, ¶g´Á, Now)

  22. If T1 Then Application.OnTime T1, "Timer1"


  23. End Sub

  24. Function TimeNext(TStart As String, TEnd As String, TFrequency As String, TNOW As Date)

  25. If TNOW < Int(TNOW) + TimeValue(TStart) Then

  26.     TimeNext = Int(TNOW) + TimeValue(TStart)
  27.    

  28. ElseIf _
  29.        TNOW >= Int(TNOW) + TimeValue(TEnd) Then
  30.    
  31.        TimeNext = 0
  32.         
  33. Else

  34.     TimeNext = Int((TNOW + TimeValue(TFrequency) + 0.5 / 86400) / TimeValue(TFrequency)) * TimeValue(TFrequency)
  35.    
  36.       
  37.       
  38. End If

  39. End Function
½Æ»s¥N½X
§Ú·Q½Ð°Ý¦³¨S¦³¤H¯à¥Î«Ü¥Õªº¥Õ¸Ü¤å¸ÑÄÀ³o­Ó¨ç¦¡ ªº³Ì«á¤@­Ó§PÂ_¦¡  
  TimeNext = Int((TNOW + TimeValue(TFrequency) + 0.5 / 86400) / TimeValue(TFrequency)) * TimeValue(TFrequency)
¬°¤°»ò§@ªÌ­n³o¼Ë¤l³]©w©O?

¤£ª¾¹D·íªì³]­pªºªB¤Í¦³¨S¦³¦Aª©¤W  ¤@°_»¡Án·PÁÂ~

¦^´_ 1# handsometrowa
  1. Option Explicit
  2. Dim T1 As Date
  3. Const ¶}©l = "08:45:05"
  4. Const µ²§ô = "13:46:08"
  5. Const ¶g´Á1 = "12:00:10 AM"
  6. '******************************
  7. '±`¼Æ¥iª½±µ³]¬°®É¶¡
  8. 'Const ¶}©l = #8:45:05 AM#
  9. 'Const µ²§ô = #1:46:08 PM#
  10. 'Const ¶g´Á1 = #12:00:10 AM#   '10¤ÀÄÁ
  11. '***************************
  12. Sub start()
  13. Call StopTimer
  14. Call Timer1
  15. End Sub
  16. Sub StopTimer()
  17. On Error Resume Next
  18. Application.OnTime T1, "Timer1", , 0
  19. T1 = Now
  20. '************************
  21. '«Øij§ï¬° Time(®É¶¡)
  22. 'T1 = Time
  23. '***********************
  24. End Sub
  25. Sub Timer1()
  26. '*********************
  27. '¨Ì§Ç¥u°õ¦æ³Ì¥ý¦¨¥ßªº±ø¥ó,¦p«á­±¦³¦¨¥ßªº±ø¥ó¬O¤£·|°õ¦æªº.
  28. 'If ±ø¥ó=True Then
  29. '    °õ¦æµ{¦¡½X
  30. 'ElseIf ±ø¥ó=True Then
  31. '    °õ¦æµ{¦¡½X
  32. 'Else             '©Ò¦³±ø¥ó³£¤£¦¨¥ß
  33. '    °õ¦æµ{¦¡½X
  34. 'End If
  35. '**********************
  36. If T1 Then  ' T1> 0 -> T1 = True ,T1= 0 -> T1= False
  37.     Sheets("¥x«ü").Range("B6000").End(xlUp).Offset(1, 0) = Sheets("sheet1").Range("B2")
  38.     Sheets("¹q«ü").Range("B6000").End(xlUp).Offset(1, 0) = Sheets("sheet1").Range("B4")
  39.     Sheets("ª÷«ü").Range("B6000").End(xlUp).Offset(1, 0) = Sheets("sheet1").Range("B6")
  40. End If
  41. '******************
  42. 'T1 =¨ç¼Æ(°Ñ¼Æ1,°Ñ¼Æ2,°Ñ¼Æ3,°Ñ¼Æ4)¶Ç¦^ªº¼Æ­È
  43. '******************
  44. T1 = TimeNext(¶}©l, µ²§ô, ¶g´Á1, Now)  '«Øij Now (¤é´Á+®É¶¡)  §ï¬° Time (®É¶¡)
  45. If T1 Then Application.OnTime T1, "Timer1"
  46. End Sub
  47. Function ATimeNext(TStart As String, TEnd As String, TFrequency As String, TNOW As Date)
  48.    'Int(TNOW)->¥h±¼¤p¼Æ(®É¶¡) ¶Ç¦^¤é´Á
  49.    If TNOW < Int(TNOW) + TimeValue(TStart) Then  'TNOW > ¤é´Á+®É¶¡
  50.         TimeNext = Int(TNOW) + TimeValue(TStart)
  51.        ' imeNext > ¤é´Á+®É¶¡
  52.     ElseIf TNOW >= Int(TNOW) + TimeValue(TEnd) Then
  53.        TimeNext = 0
  54.     Else
  55.         TimeNext = Int((TNOW + TimeValue(TFrequency) + 0.5 / 86400) / TimeValue(TFrequency)) * TimeValue(TFrequency)
  56.          '86400¬í = 24(¤p®É) * 60(¤ÀÄÁ) * 60(¬í)
  57.     End If
  58. End Function
  59. '***********************************************
  60. '±`¼Æª½±µ³]¬°®É¶¡ 'TNOW §ï¬° Time(®É¶¡)
  61. 'T1 = TimeNext(¶}©l, µ²§ô, ¶g´Á1, Time)
  62. '¨ç¼Æ°Ñ¼Æªº«¬ºA¶·­×§ï
  63. Function TimeNext(TStart As Date, TEnd As Date, TFrequency As Date, TNOW As Date) '§ï¬° Time(®É¶¡)
  64.     If TNOW < TStart Then
  65.         TimeNext = TStart
  66.     ElseIf TNOW >= TEnd Then
  67.        TimeNext = 0
  68.     Else
  69.         TimeNext = Time + TFrequency
  70.     End If
  71. End Function
  72. '***********************************************
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

·PÁª©¥Dªº¦^À³ªü ~­×§ï¤§«á§Ú¬Ý±o¤ñ¸ûÀ´¤F@@" ¦ý¬O§ÚÁÙ¬O¦³ÂI¦n©_

¬°¤°»ò§@ªÌ¥L­n³o¼Ë¤l³]©w
Int((TNOW + TimeValue(TFrequency) + 0.5 / 86400) / TimeValue(TFrequency)) * TimeValue(TFrequency)      

³o­Ó¤½¦¡¸Ì­±  

(TNOW + TimeValue(TFrequency) + 0.5 / 86400) / TimeValue(TFrequency)
µM«á¤S­¼TimeValue(TFrequency)   
³o¬O¤°»ò·N«äªü???

TOP

        ÀR«ä¦Û¦b : ¤Hªº¤ß¦a¬O¤@²¥¥Ð¡A¤g¦a¨S¦³¼½¤U¦nºØ¤l¡A¤]ªø¤£¥X¦nªºªG¹ê¡C -
ªð¦^¦Cªí ¤W¤@¥DÃD