You should accept the answer if it helped you by selecting the green tick mark on the top left of the answer. That's the encouraged practice at SO. Not only it helps future visitors, it encourages users to answer your questions.
You should post what you have tried and tell us where you're stuck. That gives us more detail, and we can quickly give an answer by copy-pasting the code with minor modifications. Questions like I-need-this,-give-me-code doesnt work in SO. In the current format the question will be closed. You may read http://stackoverflow.com/faq additionally before posting.
Do a good search on SO to ensure you're not asking a duplicated question, or else your question will be closed.
Q&A for professional and enthusiast programmers
Q&A for meta-discussion of the Stack Exchange family of Q&A websites
Q&A for peer programmer code reviews
Q&A for linguists, etymologists, and serious English language enthusiasts
Q&A for professional programmers interested in conceptual questions about software development
Q&A for computer enthusiasts and power users
Q&A for users of Linux, FreeBSD and other Un*x-like operating systems.
Q&A for people studying math at any level and professionals in related fields
Q&A for SharePoint enthusiasts
Q&A for participants in team and individual sport activities