Hi shivermetimbers,
What exactly do you mean by 'sleep' VB is naturally interupt driven, that is it 'sleeps' until an event is fired that it is programmed to react to (form load, textbox change button click etc. etc.) Do you mean 'becomes un responsive' for 5 seconds, or does something every 5 seconds.
In either case, you need a timer.
In the first case, create a global boolean variable say IsActive
On Timer Tick, toggle it's value
in every other event check IsActive before doing anything.
If you want to do something every 5 seconds, set the timer interval to 5000 (ms) and carry out your processing in the timer tick event. N.B. It's usual to disable the timer in it's own event, and reset and enable it again at the end.
Regards .. Alan
Main Topics
Browse All Topics





by: bruintjePosted on 2004-01-07 at 02:29:51ID: 10060530
Title : VB Sleep function
Source :
Description :
-----------
you could try this in a module
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Debug.Print "Started - " & Time()
Sleep 1000
Debug.Print "Ended - " & Time()
End Sub
Sleep will make the whole program wait for a amount of milliseconds
-----------
hope this helps a bit