📄
字号:
Attribute VB_Name = "TimeDelay"
Option Explicit
Public 万用表 As MultiMeter34401A
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'用于监视本线程内是否有键盘鼠标动作
Public Declare Function GetInputState Lib "user32" () As Long
'_____________________以下代码是原来的延时程序,系统开销特别大____________________________
Public Declare Function timeGetTime Lib "winmm.dll" () As Long
'Private lngStartTime As Long
'Private Sub StartTimer()
' lngStartTime = timeGetTime()
'End Sub
'Private Function EndTimer() As Double
' EndTimer = timeGetTime() - lngStartTime
'End Function
'Public Sub Delay0(msDelayTime As Long, Optional ExclusiveMode As Boolean = True)
'Dim Temp As Double
'StartTimer
'If ExclusiveMode = False Then
' Do Until EndTimer > (msDelayTime)
' If GetInputState Then DoEvents
' Loop
' Else
' Do Until EndTimer > (msDelayTime)
' Loop
'End If
'End Sub'___________________代码结束
Public Sub Delay(msDelayTime As Long, Optional ExclusiveMode As Boolean = True)
Dim LngTemp As Long, intTemp As Integer, i As Integer
LngTemp = msDelayTime \ 100
intTemp = msDelayTime Mod 100
Sleep intTemp
If ExclusiveMode = False Then
For i = 0 To LngTemp
If GetInputState Then
DoEvents
End If
Sleep 100
Next
Else
For i = 0 To LngTemp
Sleep 100
Next
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -