How do you use the Action Replay codes in a Pokemon game?

Buy an action replay cartridge or use an emulater i need help on how to put in the numbers in an action replay