- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
ÁÂÁ¦^ÂÐ ·P®¦
³o§Ú¤F¸Ñ !¦ý¦]§Ú¤TÓÄæ¦ì³£¬ODDE¸ê®Æ¹Bºâ¥X¨Óªº ©Ò¥H¦b¤@¤ÀÄÁ¤º¤]¦³O/H/L/C
©Ò¥H§Ún ...
mead µoªí©ó 2012-5-25 22:11
ªþ¤W¦p¦ó²£¥Í¦hªÅ¤O¹Dªº O/H/L/C ¤§¤èªk¡A¨ä¾l¨â¶µ¥i¥H¥t¥~¨â²ÕÅܼƨӦP®É³B²z(¦p¤G¤§»¡©ú)¡G
(¤@)- Option Explicit
- Dim timerEnabled As Boolean '
- Dim counter As Single ' ¥Ü½d¥Îp¼Æ¾¹
- Dim Ov As Single, Hv As Single, Lv As Single, Cv As Single ' ¶}½L»ù¡B³Ì°ª»ù¡B³Ì°ª»ù¡B¦¬½L»ù(¦¨¥æ»ù) µ¥³]©w¤§ÅܼơC
- Dim turnKey As Integer ' §PÂ_¨C¤@½ü°j¤W¦CÅܼƪì©lȤ§³]©w¡C
- Dim nums As Integer ' ±N¨C¹j "¦h¤Ö®É¶¡" ³B²z®É¬q¡A²¾¨ì¦¹³B¨Ó³B²z¡C
- Private Sub Workbook_Open()
- counter = 0
- nums = 30 ' ³]©w¨C¹j 30 ¬í³B²z®É¬q¡A¥ç¥i§ó§ï¦¨ 10 (¨C¹j 10 ¬í)¡B20 (¨C¹j 20 ¬í)µ¥µ¥¡C
- ' ¦¹³B¤£«Øij¨Ï¥Î 1 ¬í®É¬q¨Ó³B²z¡A¦]¬°ÁÙn¥h¨D¥X¶}½L¡B³Ì°ª¡B³Ì§C¡B¦¨¥æ»ù¡C
- timerEnabled = False
- Call timerStart ' µ{¦¡¤@±Ò©l¡A«K¥h¦Û°Ê°õ¦æ timerStart
- End Sub
- Sub timerStart()
- turnKey = 0 ' ¨C¤@½ü°j½L¤¤ªì©lȤ§³]©w¡C
- If timerEnabled Then
- Application.OnTime (Now), "ThisWorkbook.ExeSelf"
- Else
- ' ¨t²Îè³s¤W DDE ¦Ü¸ê®Æ¶×¤JExcel¤u§@ªí³æ¡A¶·¦³¤@Ó½w½Ä®É¬q¡A³o®É¦pªG°¨¤W¥h§ì¨úDDE¸ê®Æ¡A·|¦³«¬ºA¤£²Åªº¿ù»~°T®§²£¥Í¡A¨Ã¤¤Â_°õ¦æ§Çªº§@·~¡C
- Application.OnTime (Now + TimeValue("00:00:05")), "ThisWorkbook.ExeSelf"
- End If
- End Sub
- Sub ExeSelf()
- timerEnabled = True
- If IsError(Sheets("¤u§@ªí1").Range("E5").Value) Then ' °²³] E5 Äæ¦ì¬°¦hªÅ¤O¹D
- Cv = 0
- Else
- Cv = Sheets("¤u§@ªí1").Range("E5").Value ' ¦hªÅ¤O¹D¦¨¥æ»ù
- End If
-
- If (turnKey = 0 Or Ov = 0) Then ' ·í turnKey Ȭ°0¡Aªí¥Ü¨ä¬°ªì©lȳ]©w¡C¬°¦Ò¶q¨t²Îè³s¤W DDE¡A
- ' ¦³®É¦b²Ä¤@®Ú¼ÆȲ£¥Í®É Ov = Cv È¥i¯à¬° 0 (IsError()ªºª¬ºA)¡C
- Ov = Cv ' ¦hªÅ¤O¹D¶}½L»ùªì©lȳ]©w
- Hv = Cv ' ¦hªÅ¤O¹D³Ì°ª»ùªì©lȳ]©w
- Lv = Cv ' ¦hªÅ¤O¹D³Ì§C»ùªì©lȳ]©w
- End If
-
- turnKey = turnKey + 1
-
- If (Cv > Hv) Then Hv = Cv ' §PÂ_¦hªÅ¤O¹D³Ì°ª»ù
- If (Cv < Lv) Then Lv = Cv ' §PÂ_¦hªÅ¤O¹D³Ì§C»ù
- counter = counter + 1
- [F1].Value = counter ' 08:45 «á¨C¹j 30 ¬í¡A½ÐÆ[¹î F1 Äæ¦ì¼Æ¦r¬O§_·|²§°Ê¡H
-
- If (turnKey < nums) Then
- Application.OnTime (Now + TimeValue("00:00:01")), "ThisWorkbook.ExeSelf"
- Else
- If (Cv > 0) Then Call Timer
- Call timerStart
- End If
- End Sub
- Sub Timer()
- Dim str As String
-
- If (TimeValue(Now) >= TimeValue("08:45:00") And TimeValue(Now) <= TimeValue("13:46:01")) Then ' ¶}½L¡B¦¬½L®É¬q³]©w
- ' ½L¤¤³B²z¡A±N¸ê®Æ¶×¤J¼g¤J¤u§@ªí³æ¤ºÀx¦s¡C
- End If
- End Sub
½Æ»s¥N½X (¤G) §ï¥H°}¦C³B²z¡C(1. ¦hªÅ¤O¹D¡B2. ¤Ï¦V¶Õ¤O¡B3. ¥D¤O±±½L)- Dim Ov(1 To 3), Hv(1 To 3), Lv(1 To 3), Cv(1 To 3) As Single ' ¶}½L»ù¡B³Ì°ª»ù¡B³Ì°ª»ù¡B¦¬½L»ù(¦¨¥æ»ù) µ¥³]©w¤§ÅܼơC
- . ' §ï¥H°}¦C³B²z¡C(1. ¦hªÅ¤O¹D¡B2. ¤Ï¦V¶Õ¤O¡B3. ¥D¤O±±½L)
- .
- .
- Sub ExeSelf()
- timerEnabled = True
- If IsError(Sheets("¤u§@ªí1").Range("E5").Value) Then ' °²³] E5 Äæ¦ì¬°¦hªÅ¤O¹D
- Cv(1) = 0
- Cv(2) = 0
- Cv(3) = 0
- Else
- Cv(1) = Sheets("¤u§@ªí1").Range("E5").Value ' ¦hªÅ¤O¹D¦¨¥æ»ù
- Cv(2) = Sheets("¤u§@ªí1").Range("I5").Value ' ¤Ï¦V¶Õ¤O¦¨¥æ»ù
- Cv(3) = Sheets("¤u§@ªí1").Range("M5").Value ' ¥D¤O±±½L¦¨¥æ»ù
- End If
-
- If (turnKey = 0 Or Ov(1) = 0) Then ' ·í turnKey Ȭ°0¡Aªí¥Ü¨ä¬°ªì©lȳ]©w¡C¬°¦Ò¶q¨t²Îè³s¤W DDE¡A
- ' ¦³®É¦b²Ä¤@®Ú¼ÆȲ£¥Í®É Ov = Cv È¥i¯à¬° 0 (IsError()ªºª¬ºA)¡C
- Ov(1) = Cv(1) ' ¦hªÅ¤O¹D¶}½L»ùªì©lȳ]©w
- Hv(1) = Cv(1) ' ¦hªÅ¤O¹D³Ì°ª»ùªì©lȳ]©w
- Lv(1) = Cv(1) ' ¦hªÅ¤O¹D³Ì§C»ùªì©lȳ]©w
- Ov(2) = Cv(2) ' ¤Ï¦V¶Õ¤O¶}½L»ùªì©lȳ]©w
- Hv(2) = Cv(2) ' ¤Ï¦V¶Õ¤O³Ì°ª»ùªì©lȳ]©w
- Lv(2) = Cv(2) ' ¤Ï¦V¶Õ¤O³Ì§C»ùªì©lȳ]©w
- Ov(3) = Cv(3) ' ¥D¤O±±½L¶}½L»ùªì©lȳ]©w
- Hv(3) = Cv(3) ' ¥D¤O±±½L³Ì°ª»ùªì©lȳ]©w
- Lv(3) = Cv(3) ' ¥D¤O±±½L³Ì§C»ùªì©lȳ]©w
- End If
-
- turnKey = turnKey + 1
-
- If (Cv(1) > Hv(1)) Then Hv(1) = Cv(1) ' §PÂ_¦hªÅ¤O¹D³Ì°ª»ù
- If (Cv(2) > Hv(2)) Then Hv(2) = Cv(2) ' §PÂ_¤Ï¦V¶Õ¤O³Ì°ª»ù
- If (Cv(3) > Hv(3)) Then Hv(3) = Cv(3) ' §PÂ_¥D¤O±±½L³Ì°ª»ù
- If (Cv(1) < Lv(1)) Then Lv(1) = Cv(1) ' §PÂ_¦hªÅ¤O¹D³Ì§C»ù
- If (Cv(2) < Lv(2)) Then Lv(1) = Cv(2) ' §PÂ_¤Ï¦V¶Õ¤O³Ì§C»ù
- If (Cv(3) < Lv(3)) Then Lv(1) = Cv(3) ' §PÂ_¥D¤O±±½L³Ì§C»ù
- If (turnKey < nums) Then
- Application.OnTime (Now + TimeValue("00:00:01")), "ThisWorkbook.ExeSelf"
- Else
- If (Cv(1) > 0) Then Call Timer
- Call timerStart
- End If
- End Sub
½Æ»s¥N½X |
|