Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long Const VK_NUMLOCK = &H90 Const VK_SCROLL = &H91 Const VK_CAPITAL = &H14 Dim zt, ks, t Sub 开始() Dim keys(0 To 255) As Byte t = Timer ks = 1 zt = 0 For x = 1 To 250 DoEvents GetKeyboardState keys(0) If keys(39) > 127 Then zt = 0 If keys(37) > 127 Then zt = 1 If keys(40) > 127 Then ks = 0 If zt = 0 Then Cells(1, 2) = Timer - t If x = 250 Then x = 0 If ks = 0 Then Exit Sub Next x End Sub
Sub 暂停() If zt <> 0 Then zt = 0 t = Timer - Cells(1, 2) Else zt = 1 End If End Sub