Ok, first off, this code

Code:
Public Function Wait(TimeOut As Long)
  Dim TimeNow As Long  
  TimeNow = timeGetTime()
  Do
    DoEvents
  Loop While TimeNow + TimeOut > timeGetTime()
End Function
(Not my code, etc)


Does a wait function for "TimeOut" Milliseconds, but it also (because of doevents) creates lag (CPU Usage) on the computer its running on.

While this function is only used every now and again, for short periods of time, I was wondering if there was a better way to code this.




I was also wondering if there was a known way of detecting any errors that happen on the system (from any other program), to be specific, the msgbox style ones.. (Does this make sense?)