Option ExplicitPrivate Sub Text1_KeyPress(KeyAscii As Integer) Static lngTime As Long If lngTime = 0 Then lngTime = Timer Debug.Print "开始录入" ElseIf KeyAscii = 13 Then Debug.Print "停止录入,时间:" + CStr(Timer - lngTime) + "秒" lngTime = 0 End If
End Sub
Option Explicit Private Sub Text1_KeyPress(KeyAscii As Integer) Static lngTime As Single '这个最好是单精度浮点数 If lngTime = 0 Then lngTime = Timer Debug.Print "开始录入" ElseIf KeyAscii = 13 Then Debug.Print "停止录入,时间:" + CStr(Timer - lngTime) + "秒" lngTime = 0 End If End Sub
Option ExplicitPrivate Sub Text1_KeyPress(KeyAscii As Integer)
Static lngTime As Long
If lngTime = 0 Then
lngTime = Timer
Debug.Print "开始录入"
ElseIf KeyAscii = 13 Then
Debug.Print "停止录入,时间:" + CStr(Timer - lngTime) + "秒"
lngTime = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Static lngTime As Single '这个最好是单精度浮点数
If lngTime = 0 Then
lngTime = Timer
Debug.Print "开始录入"
ElseIf KeyAscii = 13 Then
Debug.Print "停止录入,时间:" + CStr(Timer - lngTime) + "秒"
lngTime = 0
End If
End Sub