From Bulbapedia, the community-driven Pokémon encyclopedia.
The box trick is a method in the core series Pokémon games that allows a Pokémon to change its stats due to effort values without leveling up. It works in all generations until Generation V. In Generation I and II, this method can be used to EV train level 100 Pokémon.
Usually, a Pokémon's stats are calculated upon leveling up; however, Pokémon stored in the PC have only the numbers used in the calculations stored, (namely the EVs, IVs and base stats) so depositing and withdrawing a Pokémon from the PC will cause its stats to be recalculated. By training or by using vitamins or stat-reducing Berries, the number of effort values can be changed between levels.
In Generation III and IV, level 100 Pokémon are unable to gain effort values through battle. This is because in these games, effort values are awarded at the same time as experience; since Pokémon at level 100 don't gain experience, they are also skipped over for effort values. This means that this trick cannot be used to alter a level 100 Pokémon's stats via leveling up; however, this trick can be used to change a level 100 Pokémon's stats by consuming vitamins or stat-reducing Berries.
In Generation V, the trick became obsolete. Effort values are applied after battle, and effort values are awarded to level 100 Pokémon. Also, EVs are automatically applied when using vitamins and wings, so it is unneeded to give EVs to Pokémon who are desired not to gain experience.