vb中如何延迟时间,程序运行到一段代码,停顿5秒,然后继续往下运行Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) DoEvents Sleep 5000
Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As Long Dim StartTm&
Private Sub Command1_Click() Call DataSend(&H67, MSComm1) Call DelayCycle(1000) Call DataSend(&H6A, MSComm1) Call DelayCycle(1000) End Sub
Public Sub DelayCycle(Optional Dtm As Long) On Error Resume Next StartTm = GetTickCount Do DoEvents Loop Until GetTickCount >= StartTm + Dtm End Sub
我用这个出现错误 VB code:
Dim NowTime As Date Dim IsExit As Boolean MsgBox "开始等待5秒" NowTime = Now IsExit = False Do DoEvents If DateDiff("s", NowTime, Now) >= 5 Then IsExit = True Loop While IsExit = False MsgBox "已等待5秒"
报这个错: compile Error sub or function not defined 和我引用这个库函数有关系吗? Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _ "GetPrivatePr ......