This is an interesting way of speeding up DoEvents, which is useful in a loop. It’s expensive, but necessary in your programme if you want it to respond to user actions. GetInputState() is cheaper, and it’s easy enough to use Windows API calls in Visual Basic code.
If GetInputState <> 0 Then DoEvents