Add a timer control to your form (from the control toolbox), give it an appropriate interval (in seconds), the put the code i gave above into the timer's "Timer" event.