Sub start()
Application.OnKey "{RIGHT}", "go"
Application.OnKey "{LEFT}", "STOPS"
Range("r2:t30,d4:d8,g4:g8,k4:k8,n4:n8").ClearContents
End Sub
Sub go()
k = 2: m = 2: n = 2
Do Until Cells(k, 18) = ""
k = k + 1
Loop
Do Until Cells(m, 19) = ""
m = m + 1
Loop
Do Until Cells(n, 20) = ""
n = n + 1
Loop
If x = 0 Or x = 2 Then
Application.OnTime Now + 0.0001, "test3"
End If
If x = 0 Then S = Timer
Select Case x
Case 0
S = Timer
x = x + 1
Case 1
S = Timer
x = x + 1
Case 2
Cells(k, 18) = (Timer - S) / 86400: S = Timer
x = x + 1
Case 3
S = Timer
x = x + 1
Case 4
Cells(m, 19) = (Timer - S) / 86400: S = Timer
x = x + 1
Case 5
Cells(n, 20) = (Timer - S) / 86400: S = Timer
x = 0
ActiveWorkbook.Save
End Select
End Sub
Sub closefuntion()
Application.OnKey "{RIGHT}"
x = 0
End Sub
Sub test3()
BEEP
End Sub
Sub STOPS()
Application.OnTime Now + 0.0001, "test3", , False
End Sub作者: Hsieh 時間: 2012-2-9 00:18
我是改成這樣, 但按了右鍵再按左鍵,再按右鍵, 卻沒發出聲音..(重點在紅字區,z=0 應該就是指z="上午 12:00:00" 吧????)
Option Explicit
Dim p, w, z As Date
Public x As Long, S As Double
Sub start()
Application.OnKey "{RIGHT}", "go"
Application.OnKey "{LEFT}", "STOPS"
End Sub
Sub go()
If x = 0 Or x = 2 Then
If z <> "上午 12:00:00" Then
w = z - Now
Application.OnTime w, "test3"
Else
p = Now + 0.000112
Application.OnTime p, "test3"
End If
End If
z = 0
End Sub
Sub test3()
BEEP
End Sub
Sub STOPS()
Application.OnTime Now + 0.0001, "test3", , False
x = x - 1
z = p
End Sub作者: HUNGCHILIN 時間: 2012-2-9 23:35
修改如下, 但還是失敗, 按下左鍵(vbKeyLeft)可以這樣用嗎?
p = Now + 0.000112
If vbKeyLeft = True Then
w = Timer
Do
DoEvents
If vbKeyLeft = True Then
z = (Timer - w) / 86400
p = p + z
Exit Do
End If
Loop
End If
Application.OnTime p, "test3"作者: Hsieh 時間: 2012-2-12 00:41
Sub cc()
a = Now + TimeValue("00:00:10")
Cells(1, 1) = a
MsgBox a
b = Cells(1, 1).Value - Now + Now
MsgBox b
End Sub
兩個紅字的NOW值是不同的作者: color790 時間: 2012-2-13 08:52