在vb.net项目的windows窗体中,添加一个Timer控件
然后创造下面的方法
'延迟操作 'delayTime单位是毫秒,1000毫秒=1秒 Public Sub Delay(ByVal delayTime As Single) Dim timerCount As Single delayTime = delayTime / 1000 timerCount = Me.Timer1.Interval + delayTime While timerCount - Me.Timer1.Interval > 0 Application.DoEvents() System.Threading.Thread.Sleep(1) timerCount = timerCount - 1 End While End Sub
调用很简单:
Delay(3000)
其中3000是毫秒,也就是3秒钟