follow is from google, may answer your question.
The onpaint event fires every time a form or control needs to be redrawn to the screen. When this happens, your drawline() sub would need to be called too for the line to be redrawn. Your start and end point variables would have to persist outside of the sub as well.