Operating instructions

R&S ESCI Basic Steps of IEC/IEEE-Bus Programming
1166.6004.12 7.9 E-1
Waiting Without Blocking the Keyboard and Mouse
A frequent problem with remote control programs using Visual Basic is to insert waiting times without
blocking the keyboard and the mouse.
If the program is to respond to user inputs also during a waiting time, control over the program events
during this time must be returned to the operating system. In Visual Basic, this is done by calling the
DoEvents function. This function causes keyboard- or mouse-triggered events to be executed by the
associated elements. For example, it allows the operation of buttons and input fields while the user waits
for an instrument setting to be completed.
The following programming example describes the Hold() function, which returns control to the
operating system for the period of the waiting time selectable in milliseconds.
Rem **********************************************************************
Rem The waiting function below expects the transfer of the desired
Rem waiting time in milliseconds. The keyboard and the mouse remain
Rem operative during the waiting period, thus allowing desired elements
Rem to be controlled
Rem **********************************************************************
Public Sub Hold(delayTime As Single)
Start = Timer 'Save timer count on calling the function
Do While Timer < Start + delayTime / 1000 'Check timer count
DoEvents 'Return control to operating system
'to enable control of desired elements as long as
'timer has not elapsed
Loop
End Sub
Rem **********************************************************************
The waiting procedure is activated simply by calling Hold(<Waiting time in milliseconds>).