On your tamagotchi go to the fourth icon across the top of the screen go to password press the middle button twice and use the first button to choose your number and the middle button to go to the next one.
Or, if it's a shop code, go onto the shop (also fourth icon), but don't enter. Stay infront of the shopkeeper and press A (the first button) three times really quickly. He should look suprised. Quickly, before it wears off, enter the shop codes. - http://www.tamatalk.com/IB/index.php?showtopic=86623