how to use event to re-write this code segment?

Printable View