First. please read up on how to properly post code in the forum.
Secondly, have you tried simply searching?.. there is a metric ton of examples in this forum alone