把Timer時間間隔調小比如
private sub timer1_timer()
static c as long
c=(c+1) mod 10
select case c
case 1
...
case 5
...
case 8
...
end select
end sub
uj5u.com熱心網友回復:
方法很簡單
timegettime+sleep
代碼
Public Function delay(T As Long)
Dim Savetime As Long
Savetime = timeGetTime '記下開始時的時間
While timeGetTime < Savetime + T '回圈等待
Sleep (10)
DoEvents '轉讓控制權
Wend
End Function
Begin VB.Form MainForm
Begin VB.Timer TimerTest
Enabled = -1 'True
Interval = 1000
Left = 0
Top = 0
End
Begin VB.Timer TimerSleep
Enabled = 0 'False
Left = 0
Top = 0
End
End
Dim done1 As Boolean
Sub sleep1(ms)
done1 = False
TimerSleep.Interval = ms
TimerSleep.Enabled = True
Do
DoEvents
Loop Until done1
End Sub
Private Sub TimerSleep_Timer()
TimerSleep.Interval = 0
TimerSleep.Enabled = False
done1 = True
End Sub
Private Sub TimerTest_Timer()
Debug.Print "Test1"
sleep1 400
Debug.Print "Test2"
sleep1 800
Debug.Print "Test3"
End Sub