Public Sub delaytime()
Dim startstart = Timer
Do While Timer < start + 1.5
Loop
End Sub
本来向实现1.5秒的延时,可是发现延时为9秒左右,请问哪里出了错?还有什么办法可以实现1.5秒的延时?

解决方案 »

  1.   

    'This project needs a button
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Command1_Click()    Me.Caption = "Your system will sleep 5 sec."
        'Sleep for 5000 milliseconds
        Sleep 5000
        Me.Caption = ""
    End Sub
    Private Sub Form_Load()
        Me.Caption = ""
        Command1.Caption = "Sleep ..."
    End Sub
      

  2.   

    还有什么办法可以实现1.5秒的延时?Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Command1_Click()    Me.Caption = "Your system will sleep 5 sec."
        'Sleep for 5000 milliseconds
        Sleep 1500    Me.Caption = ""
    End Sub
    Private Sub Form_Load()
        Me.Caption = ""
        Command1.Caption = "Sleep ..."
    End Sub
      

  3.   

    Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    Private Sub Delay(t as long)
     Dim CT as long
     CT=GetTickCount()
     Do Until GetTickCount-CT>=t
        DoEvents
     Loop
    End Sub
    Delay 1500 '延时1.5秒
      

  4.   

    你的timer控件的属性设置问题,延时的问题很简单自己好好想想一定有办法,不要一有问题就来CSND问。