Call the event loop recursively.
If Delay is specified, the function does not return until Delay seconds elapse.
If Delay is not specified, the function processes all pending events and returns immediately.
In that specific case, input events (keyboard and mouse) are ignored.
Delay is a floating point number. So, if you want to wait 100 ms, just do:
' Waits a little, letting the user interacts with the GUI
' Waits, but the user can just watch what happens...
If you call
WAIT from an event handler, you may create infinite recursions, and then stack overflows.
For example, look at the following code:
Public Sub MySerialPort_Read()
Dim sData, sTemp As String
Dim iTries As Integer
For iTries = 1 To 5
' wait a bit and read response.
' see if we got some data.
Read #Last, sTemp, Lof(Last)
sData &= sTemp
WAIT is called without reading anything on the serial port. So it is yet ready for being read, and the Read event is raised recursively again and again until the stack is full.
In that case, you can solve the problem by using the SLEEP instruction instead.